diff --git a/flake.lock b/flake.lock index 366577c..a472a5a 100644 --- a/flake.lock +++ b/flake.lock @@ -113,7 +113,25 @@ }, "naersk_2": { "inputs": { - "nixpkgs": "nixpkgs_6" + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1650265945, + "narHash": "sha256-SO8+1db4jTOjnwP++29vVgImLIfETSXyoz0FuLkiikE=", + "owner": "nmattia", + "repo": "naersk", + "rev": "e8f9f8d037774becd82fce2781e1abdb7836d7df", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "naersk_3": { + "inputs": { + "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1635777496, @@ -134,11 +152,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1648040419, - "narHash": "sha256-tq+6VYs7HAKocKzDZqHfmxqXe+tUiPs5gylfhDVgBrI=", + "lastModified": 1650903776, + "narHash": "sha256-6OWA4R9trOSkmSdsJXslYlQ+VklCIOLpZKfNTtrXHNg=", "owner": "fufexan", "repo": "nix-gaming", - "rev": "0552752da722aca36e40ef664e9c4a0928756e4e", + "rev": "448bce69b5713a3da870c77bbd6610e4c5fca2a8", "type": "github" }, "original": { @@ -165,11 +183,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1648219316, - "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=", + "lastModified": 1651024496, + "narHash": "sha256-uKSrrw/neSkxX6TXPSaMyfu7iKzFrK7F6HOt6vQefGY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634", + "rev": "d9e593ed5889f3906dc72811c45bf684be8865cf", "type": "github" }, "original": { @@ -195,11 +213,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1647966636, - "narHash": "sha256-JmxMJmdwNDgVZGG09j7XHr/zEiKKym0qEB5R3ZHXvoQ=", + "lastModified": 1650899852, + "narHash": "sha256-FNgHYq0LtGhvq1CniCg1RaH9Ngr7svm9iR6loPWCCNs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "209598e67e940ba3e42f878c407ecf96b4948615", + "rev": "ecc66a886eb7eec1d671ddfce2a0cccd12bc4807", "type": "github" }, "original": { @@ -210,11 +228,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1649490789, - "narHash": "sha256-YrhVxwoofZSx/wLZ4GYET//8vS+uqWX572zvdmP/Etg=", + "lastModified": 1650921206, + "narHash": "sha256-RGlfTC2ktqLVw0gBvZeCM//B4ig2CdQJm39sDvm0DBQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c86185d20d708013caf97a6adaa8dc6d72313c75", + "rev": "3a9e0f239d80fa134e8fcbdee4dfc793902da37e", "type": "github" }, "original": { @@ -225,6 +243,19 @@ } }, "nixpkgs_5": { + "locked": { + "lastModified": 1649490789, + "narHash": "sha256-YrhVxwoofZSx/wLZ4GYET//8vS+uqWX572zvdmP/Etg=", + "path": "/nix/store/al07yz345ymvsncz3dsmayd27dx7sfgc-source", + "rev": "c86185d20d708013caf97a6adaa8dc6d72313c75", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_6": { "locked": { "lastModified": 1625223284, "narHash": "sha256-jjLcDSU1rRiJb+n3uez23XAa7kbnPcGZTa6jIKh1GMQ=", @@ -240,7 +271,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1635956637, "narHash": "sha256-65J/mVWr0M1y/59QOGSq6jOqiYYo6zoURJqdc0EzSZA=", @@ -254,7 +285,7 @@ "type": "indirect" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1635956637, "narHash": "sha256-65J/mVWr0M1y/59QOGSq6jOqiYYo6zoURJqdc0EzSZA=", @@ -285,9 +316,7 @@ }, "rnix-lsp": { "inputs": { - "naersk": [ - "naersk" - ], + "naersk": "naersk_2", "nixpkgs": [ "nixpkgs-unstable" ], @@ -340,7 +369,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { "lastModified": 1633273832, @@ -389,8 +418,8 @@ "youmubot": { "inputs": { "flake-utils": "flake-utils", - "naersk": "naersk_2", - "nixpkgs": "nixpkgs_7" + "naersk": "naersk_3", + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1648383223, diff --git a/flake.nix b/flake.nix index 41c11cb..b2d0180 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,6 @@ # Imported apps naersk.url = "github:nix-community/naersk"; rnix-lsp.url = "github:nix-community/rnix-lsp"; - rnix-lsp.inputs.naersk.follows = "naersk"; rnix-lsp.inputs.nixpkgs.follows = "nixpkgs-unstable"; youmubot.url = "github:natsukagami/youmubot"; nix-gaming.url = github:fufexan/nix-gaming; @@ -94,6 +93,23 @@ (overlayForSystem "x86_64-linux") ]; }; + # x1c1 configuration + nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./modules/my-tinc + sops-nix.nixosModules.sops + ./nki-x1c1/configuration.nix + nixpkgsAsRegistry + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.nki = import ./home/nki-x1c1.nix; + } + (overlayForSystem "x86_64-linux") + ]; + }; # DigitalOcean node nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem { diff --git a/home/X11/default.nix b/home/X11/default.nix deleted file mode 100644 index e32e2d9..0000000 --- a/home/X11/default.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ pkgs, config, lib, ... }: - -with lib; -{ - imports = [ ./packages.nix ../modules/X11/xfce4-notifyd.nix ]; - - home.sessionVariables = { - # Set up Java font style - _JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd"; - }; - - # X Session settings - xsession.enable = true; - - # Wallpaper - home.file.wallpaper = { - source = ./. + "/wallpaper.jpg"; - target = "wallpaper.jpg"; - }; - - # Cursor - xsession.pointerCursor = { - package = pkgs.numix-cursor-theme; - name = "Numix-Cursor-Light"; - size = 32; - }; - - # MIME set ups - xdg.enable = true; - xdg.mimeApps.enable = true; - xdg.mimeApps.defaultApplications = { - "x-scheme-handler/http" = [ "firefox.desktop" ]; - "x-scheme-handler/https" = [ "firefox.desktop" ]; - "x-scheme-handler/ftp" = [ "firefox.desktop" ]; - "x-scheme-handler/ftps" = [ "firefox.desktop" ]; - "x-scheme-handler/mailspring" = [ "Mailspring.desktop" ]; - }; - - # Mimic the clipboard stuff in MacOS - home.packages = [ - (pkgs.writeShellScriptBin "pbcopy" '' - exec ${pkgs.xsel}/bin/xsel -ib - '') - (pkgs.writeShellScriptBin "pbpaste" '' - exec ${pkgs.xsel}/bin/xsel -ob - '') - ]; - - # Notification system - services.X11.xfce4-notifyd.enable = true; - - # IBus configuration - dconf.settings."desktop/ibus/general" = { - engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ]; - reload-engines = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ]; - }; - dconf.settings."desktop/ibus/general/hotkey" = { - triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "z" ]; - }; -} diff --git a/home/X11/hidpi.nix b/home/X11/hidpi.nix deleted file mode 100644 index 176d9a6..0000000 --- a/home/X11/hidpi.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ pkgs, config, lib, ... } : - -{ - # X resources for 4k monitor - home.file."4k.Xresources" = { - target = ".config/X11/.Xresources"; - text = '' - Xft.dpi: 192 - ! These might also be useful depending on your monitor and personal preference: - Xft.autohint: 0 - Xft.lcdfilter: lcddefault - Xft.hintstyle: hintfull - Xft.hinting: 1 - Xft.antialias: 1 - Xft.rgba: rgb - ''; - }; - # Load 4k Xresources - xsession.initExtra = '' - xrdb -merge ~/.config/X11/.Xresources - feh --bg-fill ~/wallpaper.jpg - ''; -} diff --git a/home/X11/i3.nix b/home/X11/i3.nix deleted file mode 100644 index 24f37f6..0000000 --- a/home/X11/i3.nix +++ /dev/null @@ -1,145 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - mod = "Mod4"; - workspaces = [ - "1: web" - "2: chat" - "3: code" - "4: music" - "5: extra" - "6: 6" - "7: 7" - "8: 8" - "9: 9" - "10: 10" - ]; - wsAttrs = builtins.listToAttrs ( - map - (i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); }) - (range 1 11) - ); - remainder = x: y: x - (builtins.div x y) * y; - range = from: to: - let - f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1); - in - f from; -in -{ - imports = [ ./i3/screenshot.nix ]; - - ## i3 window manager - xsession.windowManager.i3 = { - enable = true; - config.assigns = { - "${wsAttrs."1"}" = [{ class = "^firefox$"; }]; - "${wsAttrs."2"}" = [{ class = "^discord$"; }]; - }; - config.bars = [{ - command = "${pkgs.i3-gaps}/bin/i3bar -t"; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; - position = "top"; - colors = { - background = "#00000080"; - statusline = "#ffffff"; - separator = "#666666"; - - focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; }; - activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; }; - inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; }; - urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; }; - bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; }; - }; - }]; - config.focus.newWindow = "none"; - config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; }; - config.gaps.outer = 5; - config.gaps.inner = 5; - config.gaps.smartGaps = true; - config.modifier = mod; - config.terminal = "alacritty"; - config.window.titlebar = false; - - # Keybindings - config.keybindings = lib.mkOptionDefault ({ - ## vim-style movements - "${mod}+h" = "focus left"; - "${mod}+j" = "focus down"; - "${mod}+k" = "focus up"; - "${mod}+l" = "focus right"; - "${mod}+Shift+h" = "move left"; - "${mod}+Shift+j" = "move down"; - "${mod}+Shift+k" = "move up"; - "${mod}+Shift+l" = "move right"; - ## Splits - "${mod}+v" = "split v"; - "${mod}+Shift+v" = "split h"; - ## Run - "${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run"; - "${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'"; - } // ( - builtins.listToAttrs (lib.flatten (map - (key: [ - { - name = "${mod}+${key}"; - value = "workspace ${builtins.getAttr key wsAttrs}"; - } - { - name = "${mod}+Shift+${key}"; - value = "move to workspace ${builtins.getAttr key wsAttrs}"; - } - ]) - (builtins.attrNames wsAttrs)) - ))); - - # Workspace - config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}"; - config.startup = [ - { command = "firefox"; } - { command = "discord"; } - { command = "dex -ae i3"; } - { command = "ibus-daemon -drxR"; } - ]; - }; - - - # i3status - programs.i3status-rust.enable = true; - programs.i3status-rust.bars.default = { - icons = "material-nf"; - theme = "native"; - settings = { - icons_format = " {icon} "; - }; - blocks = [ - # { - # block = "bluetooth"; - # mac = "5C:52:30:D8:E2:9D"; - # format = "Airpods Pro {percentage}"; - # format_unavailable = "Airpods Pro XX"; - # } - { - block = "cpu"; - format = "{utilization}"; - } - { - block = "hueshift"; - } - { - block = "memory"; - } - { - block = "net"; - } - { - block = "sound"; - } - { - block = "time"; - } - ]; - }; -} - - diff --git a/home/X11/i3/screenshot.nix b/home/X11/i3/screenshot.nix deleted file mode 100644 index a315167..0000000 --- a/home/X11/i3/screenshot.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, config, lib, ... }: - -with lib; -{ - xsession.windowManager.i3.config = { - startup = [ { command = "${pkgs.flameshot}/bin/flameshot"; } ]; - keybindings = mkOptionDefault { "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; }; - }; -} diff --git a/home/X11/packages.nix b/home/X11/packages.nix deleted file mode 100644 index 07406aa..0000000 --- a/home/X11/packages.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - # Override nss to open links in Firefox (https://github.com/NixOS/nixpkgs/issues/78961) - discordPkg = pkgs.unstable.discord.override { nss = pkgs.unstable.nss; }; -in -{ - imports = [ ./alacritty.nix ./i3.nix ]; - - home.packages = (with pkgs; [ - ## GUI stuff - gnome.cheese # Webcam check - evince # PDF reader - gparted - pkgs.unstable.vscode - feh - deluge # Torrent client - mailspring - discordPkg - pavucontrol # PulseAudio control panel - - ## CLI stuff - xsel # Clipboard management - dex # .desktop file management, startup - sct # Display color temperature - ]); - - # Gnome-keyring - services.gnome-keyring.enable = true; - - # Picom: X Compositor - services.picom = { - enable = true; - blur = true; - fade = true; - fadeDelta = 3; - shadow = true; - }; -} diff --git a/home/common-linux.nix b/home/common-linux.nix new file mode 100644 index 0000000..36b3159 --- /dev/null +++ b/home/common-linux.nix @@ -0,0 +1,22 @@ +{ pkgs, config, lib, ... }: +with lib; { + imports = [ + ./modules/linux/graphical + ./modules/X11/xfce4-notifyd.nix + ]; + config = (mkIf (strings.hasSuffix "linux" pkgs.system) { + ## Gnome-keyring + services.gnome-keyring = { + enable = true; + components = [ "pkcs11" "secrets" "ssh" ]; + }; + services.gpg-agent.enable = true; + services.gpg-agent.pinentryFlavor = "gnome3"; + + # Git "safe-directory" + programs.git.extraConfig.safe.directory = [ + "${config.home.homeDirectory}/.config/nixpkgs" + ]; + }); +} + diff --git a/home/common.nix b/home/common.nix index fd354fa..070e594 100644 --- a/home/common.nix +++ b/home/common.nix @@ -5,6 +5,8 @@ ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix + ./modules/programs/my-sway + ./common-linux.nix ]; # Let Home Manager install and manage itself. @@ -55,7 +57,7 @@ bottom ## To do tunneling with cloudflare - cloudflared + pkgs.unfree.cloudflared # Databases postgresql diff --git a/home/fish/fish.nix b/home/fish/fish.nix index 37a5f57..3e979f4 100644 --- a/home/fish/fish.nix +++ b/home/fish/fish.nix @@ -30,6 +30,11 @@ if test -e /opt/homebrew/bin/brew /opt/homebrew/bin/brew shellenv | source end + + # Gnome-keyring startup + if type -q gnome-keyring-daemon + set -x (gnome-keyring-daemon --start | string split "=") + end ''; interactiveShellInit = '' @@ -50,6 +55,9 @@ ## Set some kak-focused keybindings bind -M default gi beginning-of-line bind -M default gl end-of-line + + # Set up direnv + ${pkgs.direnv}/bin/direnv hook fish | source ''; plugins = [ { diff --git a/home/images/wallpaper_0.png b/home/images/wallpaper_0.png new file mode 100644 index 0000000..ed9be60 Binary files /dev/null and b/home/images/wallpaper_0.png differ diff --git a/home/X11/wallpaper.jpg b/home/images/wallpaper_1.png similarity index 100% rename from home/X11/wallpaper.jpg rename to home/images/wallpaper_1.png diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index ccb0600..8b4640a 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -1,16 +1,13 @@ -{ pkgs, config, lib, ... } : +{ pkgs, config, lib, ... }: { imports = [ - # Common configuration - ./common.nix - # Set up X11-specific common configuration - ./X11/default.nix - ./X11/hidpi.nix # Enable hiDPI - # We use our own firefox - ./firefox.nix - # osu! - ./osu.nix + # Common configuration + ./common.nix + # We use our own firefox + ./firefox.nix + # osu! + ./osu.nix ]; # Home Manager needs a bit of information about you and the @@ -20,17 +17,23 @@ # More packages home.packages = (with pkgs; [ - # CLI stuff - python - zip - # TeX - texlive.combined.scheme-full + # CLI stuff + python + zip + # TeX + texlive.combined.scheme-full - # Java & sbt - openjdk11 - sbt + # Java & sbt + openjdk11 + sbt ]); + # Enable X11 configuration + linux.graphical.type = "x11"; + linux.graphical.wallpaper = ./images/wallpaper_1.png; + linux.graphical.x11.hidpi = true; + linux.graphical.x11.enablei3 = true; + # This value determines the Home Manager release that your # configuration is compatible with. This helps avoid breakage # when a new Home Manager release introduces backwards diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index 5f372a6..60c4010 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -39,7 +39,7 @@ let src = pkgs.fetchFromGitHub { owner = pname; repo = pname; - rev = "v${version}"; + rev = rev; sha256 = "sha256-xjfYdwDNp2Ak7t0dfp0SWJcFVve2iDcEKzDukcxVmzI="; # sha256 = lib.fakeSha256; }; diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc index 34b0bd6..7d16fa9 100644 --- a/home/kakoune/kakrc +++ b/home/kakoune/kakrc @@ -1,7 +1,7 @@ # Color scheme -# colorscheme github -# face global Default rgb:121213,default -# face global BufferPadding rgb:A0A0A0,default +colorscheme github +face global Default rgb:121213,default +face global BufferPadding rgb:A0A0A0,default face global MenuForeground blue,white+bF face global MenuBackground bright-blue,white+F face global Information bright-blue,white @@ -42,13 +42,13 @@ map global goto f -docstring "current grep-jump match" ': grep-jump' # System clipboard interactions hook global RegisterModified '"' %{ nop %sh{ - printf "%s" "$kak_main_reg_dquote" | pbcopy + printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & }} map global user P -docstring "Paste before cursor from clipboard" '! pbpaste' map global user p -docstring "Paste after cursor from clipboard" ' pbpaste' map global user R -docstring "Replace selection with text from clipboard" '! pbpaste' define-command -params 0 -docstring "Copy line down" copyline %{ - execute-keys -draft 'y'%val{count}'P' + execute-keys -draft 'xy'%val{count}'P' } map global normal <+> -docstring "Copy line down" ': copyline' define-command -params 0 -docstring "Delete current character" delete-one %{ diff --git a/home/X11/alacritty.nix b/home/modules/linux/graphical/alacritty.nix similarity index 57% rename from home/X11/alacritty.nix rename to home/modules/linux/graphical/alacritty.nix index 84e1a49..a0a4e11 100644 --- a/home/X11/alacritty.nix +++ b/home/modules/linux/graphical/alacritty.nix @@ -1,22 +1,34 @@ { pkgs, config, lib, ... }: +with lib; +let + cfg = config.linux.graphical.alacritty; +in { - home.packages = [ - ]; - - programs.alacritty = { + options.linux.graphical.alacritty = { + enable = mkOption { + type = types.bool; + default = true; + }; + package = mkOption { + type = types.package; + default = pkgs.alacritty; + }; + }; + config.programs.alacritty = mkIf (config.linux.graphical.type != null && cfg.enable) { enable = true; - package = pkgs.unstable.alacritty; + package = cfg.package; settings = { - window.opacity = 0.95; + window.opacity = mkIf (strings.hasPrefix "0.10" cfg.package.version) 0.9; + background_opacity = mkIf (strings.hasPrefix "0.9" cfg.package.version) 0.9; font = { size = 14.0; normal.family = "Fantasque Sans Mono Nerd Font"; }; shell = { program = "/bin/sh"; - args = [ "-ic" "fish" ]; + args = [ "-ic" "${config.programs.fish.package}/bin/fish" ]; }; colors = { # Default colors @@ -43,6 +55,10 @@ bright.cyan = "0x4fb8cc"; bright.white = "0xf1f1f1"; }; + + key_bindings = [ + { key = "C"; mods = "Alt|Control"; action = "SpawnNewInstance"; } + ]; }; }; } diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix new file mode 100644 index 0000000..dc80556 --- /dev/null +++ b/home/modules/linux/graphical/default.nix @@ -0,0 +1,72 @@ +{ pkgs, lib, config, ... }: +with lib; +let + cfg = config.linux.graphical; +in +{ + imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ]; + options.linux.graphical = { + type = mkOption { + type = types.nullOr (types.enum [ "x11" "wayland" ]); + description = "Enable linux graphical configurations, with either 'x11' or 'wayland'"; + default = null; + }; + wallpaper = mkOption { + type = types.oneOf [ types.str types.path ]; + description = "Path to the wallpaper file"; + default = ""; + }; + }; + config = mkIf (cfg.type != null) { + # Packages + + home.packages = (with pkgs; [ + ## GUI stuff + gnome.cheese # Webcam check + evince # PDF reader + gparted + pkgs.unstable.vscode + feh + deluge # Torrent client + mailspring + unstable.discord + pavucontrol # PulseAudio control panel + + ## CLI stuff + dex # .desktop file management, startup + sct # Display color temperature + ]); + + # Cursor + xsession.pointerCursor = { + package = pkgs.numix-cursor-theme; + name = "Numix-Cursor-Light"; + size = 32; + }; + + # MIME set ups + xdg.enable = true; + xdg.mimeApps.enable = true; + xdg.mimeApps.defaultApplications = { + "x-scheme-handler/http" = [ "firefox.desktop" ]; + "x-scheme-handler/https" = [ "firefox.desktop" ]; + "x-scheme-handler/ftp" = [ "firefox.desktop" ]; + "x-scheme-handler/ftps" = [ "firefox.desktop" ]; + "x-scheme-handler/mailspring" = [ "Mailspring.desktop" ]; + }; + + home.sessionVariables = { + # Set up Java font style + _JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd"; + }; + + # IBus configuration + dconf.settings."desktop/ibus/general" = { + engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ]; + reload-engines = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ]; + }; + dconf.settings."desktop/ibus/general/hotkey" = { + triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "z" ]; + }; + }; +} diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix new file mode 100644 index 0000000..5f805b6 --- /dev/null +++ b/home/modules/linux/graphical/wayland.nix @@ -0,0 +1,28 @@ +{ pkgs, config, lib, ... }: +with lib; +{ + config = mkIf (config.linux.graphical.type == "wayland") { + # Additional packages + home.packages = with pkgs; [ + wl-clipboard # Clipboard management + + # Mimic the clipboard stuff in MacOS + (pkgs.writeShellScriptBin "pbcopy" '' + exec ${pkgs.wl-clipboard}/bin/wl-copy + '') + (pkgs.writeShellScriptBin "pbpaste" '' + exec ${pkgs.wl-clipboard}/bin/wl-paste -n + '') + ]; + + # Notification system + programs.mako = { + enable = true; + borderRadius = 5; + }; + + # Forward wallpaper settings to sway + programs.my-sway.wallpaper = config.linux.graphical.wallpaper; + }; +} + diff --git a/home/modules/linux/graphical/x11.nix b/home/modules/linux/graphical/x11.nix new file mode 100644 index 0000000..4444825 --- /dev/null +++ b/home/modules/linux/graphical/x11.nix @@ -0,0 +1,35 @@ +{ pkgs, config, lib, ... }: +with lib; +{ + imports = [ ./x11/hidpi.nix ./x11/i3.nix ]; + config = mkIf (config.linux.graphical.type == "x11") { + # X Session settings + xsession.enable = true; + + # Additional packages + home.packages = with pkgs; [ + xsel # Clipboard management + + # Mimic the clipboard stuff in MacOS + (pkgs.writeShellScriptBin "pbcopy" '' + exec ${pkgs.xsel}/bin/xsel -ib + '') + (pkgs.writeShellScriptBin "pbpaste" '' + exec ${pkgs.xsel}/bin/xsel -ob + '') + ]; + + # Notification system + services.X11.xfce4-notifyd.enable = true; + + # Picom: X Compositor + services.picom = { + enable = true; + blur = true; + fade = true; + fadeDelta = 3; + shadow = true; + }; + }; +} + diff --git a/home/modules/linux/graphical/x11/hidpi.nix b/home/modules/linux/graphical/x11/hidpi.nix new file mode 100644 index 0000000..2ec8e09 --- /dev/null +++ b/home/modules/linux/graphical/x11/hidpi.nix @@ -0,0 +1,30 @@ +{ pkgs, config, lib, ... }: + +with lib; +let + cfg = config.linux.graphical.x11; +in +{ + options.linux.graphical.x11.hidpi = mkEnableOption "Enable hiDPI mode for X11"; + + config = mkIf cfg.hidpi { + # X resources for 4k monitor + home.file."4k.Xresources" = { + target = ".config/X11/.Xresources"; + text = '' + Xft.dpi: 192 + ! These might also be useful depending on your monitor and personal preference: + Xft.autohint: 0 + Xft.lcdfilter: lcddefault + Xft.hintstyle: hintfull + Xft.hinting: 1 + Xft.antialias: 1 + Xft.rgba: rgb + ''; + }; + # Load 4k Xresources + xsession.initExtra = '' + xrdb -merge ~/.config/X11/.Xresources + ''; + }; +} diff --git a/home/modules/linux/graphical/x11/i3.nix b/home/modules/linux/graphical/x11/i3.nix new file mode 100644 index 0000000..b92c7dc --- /dev/null +++ b/home/modules/linux/graphical/x11/i3.nix @@ -0,0 +1,158 @@ +{ pkgs, config, lib, ... }: + +with lib; +let + cfg = config.linux.graphical.x11; + + mod = "Mod4"; + workspaces = [ + "1: web" + "2: chat" + "3: code" + "4: music" + "5: extra" + "6: 6" + "7: 7" + "8: 8" + "9: 9" + "10: 10" + ]; + wsAttrs = builtins.listToAttrs ( + map + (i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); }) + (range 1 11) + ); + remainder = x: y: x - (builtins.div x y) * y; + range = from: to: + let + f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1); + in + f from; +in +{ + imports = [ ./i3/screenshot.nix ]; + + options.linux.graphical.x11.enablei3 = mkEnableOption "Enable i3"; + + config = mkIf (cfg.enablei3) { + + ## i3 window manager + xsession.windowManager.i3 = { + enable = true; + config.assigns = { + "${wsAttrs."1"}" = [{ class = "^firefox$"; }]; + "${wsAttrs."2"}" = [{ class = "^discord$"; }]; + }; + config.bars = [{ + command = "${pkgs.i3-gaps}/bin/i3bar -t"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; + position = "top"; + colors = { + background = "#00000080"; + statusline = "#ffffff"; + separator = "#666666"; + + focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; }; + activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; }; + inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; }; + urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; }; + bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; }; + }; + }]; + config.focus.newWindow = "none"; + config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; }; + config.gaps.outer = 5; + config.gaps.inner = 5; + config.gaps.smartGaps = true; + config.modifier = mod; + config.terminal = "alacritty"; + config.window.titlebar = false; + + # Keybindings + config.keybindings = lib.mkOptionDefault ({ + ## vim-style movements + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + "${mod}+Shift+h" = "move left"; + "${mod}+Shift+j" = "move down"; + "${mod}+Shift+k" = "move up"; + "${mod}+Shift+l" = "move right"; + ## Splits + "${mod}+v" = "split v"; + "${mod}+Shift+v" = "split h"; + ## Run + "${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + "${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'"; + } // ( + builtins.listToAttrs (lib.flatten (map + (key: [ + { + name = "${mod}+${key}"; + value = "workspace ${builtins.getAttr key wsAttrs}"; + } + { + name = "${mod}+Shift+${key}"; + value = "move to workspace ${builtins.getAttr key wsAttrs}"; + } + ]) + (builtins.attrNames wsAttrs)) + ))); + + # Workspace + config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}"; + config.startup = [ + { command = "firefox"; } + { command = "discord"; } + { command = "dex -ae i3"; } + { command = "ibus-daemon -drxR"; } + ] ++ + ( + if (config.linux.graphical.wallpaper != "") + then [{ command = "${pkgs.feh}/bin/feh --bg-fill ${config.linux.graphical.wallpaper}"; }] + else [ ] + ); + }; + + + # i3status + programs.i3status-rust.enable = true; + programs.i3status-rust.bars.default = { + icons = "material-nf"; + theme = "native"; + settings = { + icons_format = " {icon} "; + }; + blocks = [ + # { + # block = "bluetooth"; + # mac = "5C:52:30:D8:E2:9D"; + # format = "Airpods Pro {percentage}"; + # format_unavailable = "Airpods Pro XX"; + # } + { + block = "cpu"; + format = "{utilization}"; + } + { + block = "hueshift"; + } + { + block = "memory"; + } + { + block = "net"; + } + { + block = "sound"; + } + { + block = "time"; + } + ]; + }; + }; +} + + diff --git a/home/modules/linux/graphical/x11/i3/screenshot.nix b/home/modules/linux/graphical/x11/i3/screenshot.nix new file mode 100644 index 0000000..ab1a580 --- /dev/null +++ b/home/modules/linux/graphical/x11/i3/screenshot.nix @@ -0,0 +1,9 @@ +{ pkgs, config, lib, ... }: + +with lib; +{ + xsession.windowManager.i3.config = mkIf (config.linux.graphical.x11.enablei3) { + startup = [{ command = "${pkgs.flameshot}/bin/flameshot"; }]; + keybindings = mkOptionDefault { "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; }; + }; +} diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix new file mode 100644 index 0000000..5fb4372 --- /dev/null +++ b/home/modules/programs/my-sway/default.nix @@ -0,0 +1,453 @@ +{ pkgs, lib, config, ... }: +with lib; +let + cfg = config.programs.my-sway; + + mod = "Mod4"; + # List of workspaces + workspaces = [ + "1: web" + "2: chat" + "3: code" + "4: music" + "5: extra" + "6: 6" + "7: 7" + "8: 8" + "9: 9" + "10: 10" + ]; + wsAttrs = builtins.listToAttrs ( + map + (i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); }) + (range 1 11) + ); + remainder = x: y: x - (builtins.div x y) * y; + range = from: to: + let + f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1); + in + f from; + +in +{ + imports = [ ./ibus.nix ]; + + options.programs.my-sway = { + enable = mkEnableOption "Enable the sway configuration"; + fontSize = mkOption { + type = types.float; + description = "The default font size"; + }; + enableTouchpad = mkOption { + type = types.bool; + description = "Whether to enable the touchpad"; + default = true; + }; + wallpaper = mkOption { + type = types.oneOf [ types.path types.str ]; + description = "Path to the wallpaper to be used"; + default = ""; + }; + terminal = mkOption { + type = types.str; + description = "The command to the terminal emulator to be used"; + default = "${pkgs.alacritty}/bin/alacritty"; + }; + }; + + config.wayland.windowManager.sway = mkIf cfg.enable { + enable = true; + + config = { + ### Inputs + # + # Touchpad + input."type=touchpad" = { + events = if cfg.enableTouchpad then "enabled" else "disabled"; + }; + # TODO: Keyboard + + ### Outputs + # + # Wallpaper + output."*".bg = if cfg.wallpaper == "" then "#000000 solid_color" else "${cfg.wallpaper} fill"; + + ### Programs + # + # Terminal + terminal = cfg.terminal; + menu = "${pkgs.dmenu}/bin/dmenu_path | ${pkgs.bemenu}/bin/bemenu | ${pkgs.findutils}/bin/xargs swaymsg exec --"; + # Startup + startup = [ + # Dex for autostart + { command = "${pkgs.dex}/bin/dex -ae sway"; } + # Waybar + { command = "systemctl --user restart waybar"; always = true; } + # Startup programs + { command = "${pkgs.flameshot}/bin/flameshot"; } + { command = "${pkgs.firefox}/bin/firefox"; } + { command = "${pkgs.unstable.discord}/bin/discord"; } + ]; + + ### Keybindings + # + # Main modifier + modifier = mod; + keybindings = lib.mkOptionDefault + ({ + ## Splits + "${mod}+v" = "split v"; + "${mod}+Shift+v" = "split h"; + ## Run + "${mod}+r" = "exec ${config.wayland.windowManager.sway.config.menu}"; + "${mod}+Shift+r" = "mode resize"; + ## Screenshot + "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; + ## Locking + "${mod}+semicolon" = "exec ${pkgs.swaylock}/bin/swaylock" + + (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fit") + + " -l -k"; + } // ( + # Map the workspaces + builtins.listToAttrs (lib.flatten (map + (key: [ + { + name = "${mod}+${key}"; + value = "workspace ${builtins.getAttr key wsAttrs}"; + } + { + name = "${mod}+Shift+${key}"; + value = "move to workspace ${builtins.getAttr key wsAttrs}"; + } + ]) + (builtins.attrNames wsAttrs)) + ))); + + ### Fonts + # + fonts = { + names = [ "monospace" "FontAwesome5Free" ]; + size = cfg.fontSize; + }; + + ### Workspaces + # + # Default workspace + defaultWorkspace = "workspace ${builtins.elemAt workspaces 0}"; + # Back and Forth + workspaceAutoBackAndForth = true; + + ### Windows + # + # Border + window.border = 2; + # Assigning windows to workspaces + assigns = { + "${builtins.elemAt workspaces 0}" = [ + { class = "^firefox$"; } + ]; + "${builtins.elemAt workspaces 1}" = [ + { class = "^Discord$"; } + ]; + }; + focus.followMouse = true; + focus.mouseWarping = true; + focus.newWindow = "urgent"; + # Gaps + gaps.outer = 3; + gaps.inner = 4; + gaps.smartBorders = "on"; + gaps.smartGaps = true; + + ### Bars + # + # Enable top bar, as waybar + bars = [{ + command = config.programs.waybar.package + "/bin/waybar"; + position = "top"; + }]; + }; + ### Misc + # + # xwayland + xwayland = true; + # swaynag + swaynag.enable = true; + # Environment Variables + extraSessionCommands = '' + export MOZ_ENABLE_WAYLAND=1 + export SDL_VIDEODRIVER=wayland + export QT_QPA_PLATFORM=wayland + export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" + ''; + # Extra + wrapperFeatures.base = true; + wrapperFeatures.gtk = true; + + # Fix D-Bus starting up + extraConfig = '' + exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK && \ + hash dbus-update-activation-environment 2>/dev/null && \ + dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK && \ + systemctl --user start sway-session.target + ''; + }; + + config.systemd.user.targets.sway-session = mkIf cfg.enable { + Unit = { + Description = "sway compositor session"; + Documentation = [ "man:systemd.special(7)" ]; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + }; + + config.programs.waybar = mkIf cfg.enable { + enable = true; + settings = [ + # Top bar + { + position = "top"; + modules-left = [ + "sway/workspaces" + "sway/mode" + ]; + modules-center = [ + "sway/window" + ]; + modules-right = [ + "tray" + "pulseaudio" + "network" + "cpu" + "memory" + "temperature" + "backlight" + "battery" + "battery#bat2" + "clock" + ]; + + modules = { + "sway/mode" = { + format = "{}"; + }; + "tray" = { + icon-size = 21; + spacing = 10; + }; + "clock" = { + tooltip-format = "{:%Y-%m-%d | %H:%M}"; + format-alt = "{:%Y-%m-%d}"; + }; + "cpu" = { + format = "{usage}% "; + }; + "memory" = { + format = "{}% "; + }; + "temperature" = { + # thermal-zone = 2; + # hwmon-path" = "/sys/class/hwmon/hwmon2/temp1_input"; + critical-threshold = 80; + # format-critical = "{temperatureC}°C "; + format = "{temperatureC}°C "; + }; + "backlight" = { + # device = "acpi_video1"; + format = "{percent}% {icon}"; + states = [ 0 50 ]; + format-icons = [ "" "" ]; + }; + "battery" = { + states = { + good = 95; + warning = 30; + critical = 15; + }; + format = "{capacity}% {icon}"; + # format-good = ""; # An empty format will hide the module + # format-full = ""; + format-icons = [ "" "" "" "" "" ]; + }; + "battery#bat2" = { + bat = "BAT2"; + }; + "network" = { + # interface = wlp2s0 # (Optional) To force the use of this interface + format-wifi = "{essid} ({signalStrength}%) "; + format-ethernet = "{ifname}: {ipaddr}/{cidr} "; + format-disconnected = "Disconnected ⚠"; + interval = 7; + }; + "pulseaudio" = { + # scroll-step = 1; + format = "{volume}% {icon}"; + format-bluetooth = "{volume}% {icon}"; + format-muted = ""; + format-icons = { + headphones = ""; + handsfree = ""; + headset = ""; + phone = ""; + portable = ""; + car = ""; + default = [ "" "" ]; + }; + on-click = "pavucontrol"; + }; + }; + } + ]; + style = '' + * { + border: none; + border-radius: 0; + font-family: IBM Plex Mono,'Font Awesome 5', 'SFNS Display', Helvetica, Arial, sans-serif; + font-size: 13px; + min-height: 0; + } + + window#waybar { + background: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + } + + window#waybar.hidden { + opacity: 0.0; + } + /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ + #workspaces button { + padding: 0 5px; + background: transparent; + color: #ffffff; + border-bottom: 3px solid transparent; + } + + #workspaces button.focused { + background: #64727D; + border-bottom: 3px solid #ffffff; + } + + #workspaces button.urgent { + background-color: #eb4d4b; + } + + #mode { + background: #64727D; + border-bottom: 3px solid #ffffff; + } + + #clock, #battery, #cpu, #memory, #temperature, #backlight, #network, #pulseaudio, #custom-media, #tray, #mode, #idle_inhibitor { + padding: 0 10px; + margin: 0 5px; + } + + #clock { + background-color: #64727D; + } + + #battery { + background-color: #ffffff; + color: #000000; + } + + #battery.charging { + color: #ffffff; + background-color: #26A65B; + } + + @keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } + } + + #battery.critical:not(.charging) { + background: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; + } + + #cpu { + background: #2ecc71; + color: #000000; + } + + #memory { + background: #9b59b6; + } + + #backlight { + background: #90b1b1; + } + + #network { + background: #2980b9; + } + + #network.disconnected { + background: #f53c3c; + } + + #pulseaudio { + background: #f1c40f; + color: #000000; + } + + #pulseaudio.muted { + background: #90b1b1; + color: #2a5c45; + } + + #custom-media { + background: #66cc99; + color: #2a5c45; + } + + .custom-spotify { + background: #66cc99; + } + + .custom-vlc { + background: #ffa000; + } + + #temperature { + background: #f0932b; + } + + #temperature.critical { + background: #eb4d4b; + } + + #tray { + background-color: #2980b9; + } + + #idle_inhibitor { + background-color: #2d3436; + } + + #idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; + } + ''; + }; + + config.home.packages = mkIf cfg.enable (with pkgs; [ + # Needed for QT_QPA_PLATFORM + qt5.qtwayland + # For waybar + font-awesome + ]); +} diff --git a/home/modules/programs/my-sway/ibus.nix b/home/modules/programs/my-sway/ibus.nix new file mode 100644 index 0000000..c23ab10 --- /dev/null +++ b/home/modules/programs/my-sway/ibus.nix @@ -0,0 +1,49 @@ +{ pkgs, config, lib, ... }: +with lib; +let + cfg = config.programs.my-sway; + + # Set up an ibus script + ibusNext = ( + let + input-methods = [ "xkb:us::eng" "mozc-jp" "Bamboo" ]; + next = m: + let + nextRec = l: + if (length l == 1) + then head input-methods + else if (m == head l) + then (head (tail l)) + else nextRec (tail l); + in + nextRec input-methods; + inputCase = m: '' + if test $current = "${m}" + ${pkgs.libnotify}/bin/notify-send \ + -a ibus \ + -u low \ + -t 3000 \ + "${next m}" \ + "Input engine changed" + ${pkgs.ibus}/bin/ibus engine ${next m} + end + ''; + in + pkgs.writeScriptBin "ibus-next-engine" '' + #! ${pkgs.fish}/bin/fish + + set current (${pkgs.ibus}/bin/ibus engine) + + ${strings.concatMapStrings inputCase input-methods} + '' + ); + +in +{ + config = mkIf cfg.enable { + wayland.windowManager.sway.config.keybindings = mkOptionDefault { + "${config.wayland.windowManager.sway.config.modifier}+z" = "exec ${ibusNext}/bin/ibus-next-engine"; + }; + }; +} + diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix new file mode 100644 index 0000000..26a62d0 --- /dev/null +++ b/home/nki-x1c1.nix @@ -0,0 +1,54 @@ +{ pkgs, config, lib, ... }: + +{ + imports = [ + # Common configuration + ./common.nix + # We use our own firefox + # ./firefox.nix + # osu! + # ./osu.nix + ]; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "nki"; + home.homeDirectory = "/home/nki"; + + # More packages + home.packages = (with pkgs; [ + # CLI stuff + python + zip + # TeX + texlive.combined.scheme-full + + # Java & sbt + openjdk11 + sbt + ]); + + # Graphical set up + linux.graphical.type = "wayland"; + linux.graphical.wallpaper = ./images/wallpaper_0.png; + # Enable sway + programs.my-sway.enable = true; + programs.my-sway.fontSize = 14.0; + # Keyboard support + wayland.windowManager.sway.config = { + input."1:1:AT_Translated_Set_2_keyboard" = { + xkb_options = "ctrl:swapcaps"; + }; + }; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "21.05"; +} + diff --git a/modules/services/input-remapper.nix b/modules/services/input-remapper.nix new file mode 100644 index 0000000..e550aa9 --- /dev/null +++ b/modules/services/input-remapper.nix @@ -0,0 +1,32 @@ +# This is a stub, until 22.05 merge this +{ pkgs, lib, config, ... }: + +with lib; + +let cfg = config.services.input-remapper; in +{ + options = { + services.input-remapper = { + enable = mkEnableOption "input-remapper, an easy to use tool to change the mapping of your input device buttons."; + package = mkOption { + type = types.package; + default = pkgs.unstable.input-remapper; + }; + enableUdevRules = mkEnableOption "udev rules added by input-remapper to handle hotplugged devices. Currently disabled by default due to https://github.com/sezanzeb/input-remapper/issues/140"; + serviceWantedBy = mkOption { + default = [ "graphical.target" ]; + example = [ "multi-user.target" ]; + type = types.listOf types.str; + description = "Specifies the WantedBy setting for the input-remapper service."; + }; + }; + }; + + config = mkIf cfg.enable { + services.udev.packages = mkIf cfg.enableUdevRules [ cfg.package ]; + services.dbus.packages = [ cfg.package ]; + systemd.packages = [ cfg.package ]; + environment.systemPackages = [ cfg.package ]; + systemd.services.input-remapper.wantedBy = cfg.serviceWantedBy; + }; +} diff --git a/modules/services/pam/gnome-keyring.nix b/modules/services/pam/gnome-keyring.nix new file mode 100644 index 0000000..aef01a2 --- /dev/null +++ b/modules/services/pam/gnome-keyring.nix @@ -0,0 +1,12 @@ +{ pkgs, config, lib, ... }: +with lib; +let + cfg = config.nki.services.pam; +in +{ + options.nki.services.pam.enableGnomeKeyring = mkEnableOption "Enable gnome-keyring on login"; + config = mkIf cfg.enableGnomeKeyring { + security.pam.services.login.enableGnomeKeyring = true; + security.pam.services.login.gnupg.enable = true; + }; +} diff --git a/modules/services/swaylock.nix b/modules/services/swaylock.nix new file mode 100644 index 0000000..6a7e317 --- /dev/null +++ b/modules/services/swaylock.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: +with lib; +let + cfg = config.services.swaylock; +in +{ + options.services.swaylock = { + enable = mkEnableOption "Enable swaylock"; + package = mkOption { + type = types.package; + default = pkgs.swaylock; + }; + }; + config = mkIf cfg.enable { + security.pam.services.swaylock.text = readFile "${cfg.package}/etc/pam.d/swaylock"; + }; +} diff --git a/nki-x1c1/configuration.nix b/nki-x1c1/configuration.nix new file mode 100644 index 0000000..f38b10c --- /dev/null +++ b/nki-x1c1/configuration.nix @@ -0,0 +1,170 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + # Fonts + ../modules/personal/fonts + # Some PAM stuff + ../modules/services/pam/gnome-keyring.nix + ../modules/services/swaylock.nix + ../modules/services/input-remapper.nix + ]; + # Use the latest kernel + boot.kernelPackages = pkgs.linuxPackages_latest; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Enable nix commands and nix flakes + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + + networking.hostName = "nki-x1c1"; # Define your hostname. + networking.wireless.iwd.enable = true; # Enables wireless support via iwd. + + # Set your time zone. + time.timeZone = "America/Toronto"; + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.wlan0.useDHCP = true; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + services.xserver.autorun = false; + + + # Enable the Plasma 5 Desktop Environment. + # services.xserver.displayManager.sddm.enable = true; + # services.xserver.desktopManager.plasma5.enable = true; + + environment.loginShellInit = '' + if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then + exec sway + fi + ''; + + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e"; + i18n.inputMethod.enabled = "ibus"; + i18n.inputMethod.ibus.engines = (with pkgs.ibus-engines; [ bamboo mozc libpinyin ]); + + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + sound.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + # hardware.pulseaudio = { + # enable = true; + # extraModules = [ pkgs.pulseaudio-modules-bt ]; + # package = pkgs.pulseaudioFull; + # }; + + # Enable bluetooth + hardware.bluetooth.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.nki = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + kakoune # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + fish + firefox + + ## System Monitoring tools + usbutils + pciutils + ]; + + # Gnome-keyring is useful + services.gnome.gnome-keyring.enable = true; + + ## Environment variables + environment.variables = { + # Input method overrides + GTK_IM_MODULE = "ibus"; + QT_IM_MODULE = "ibus"; + "XMODIFIERS=@im" = "ibus"; + + # Basic editor setup + EDITOR = "kak"; + VISUAL = "kak"; + }; + + # Enable some xdg stuff + services.dbus.enable = true; + xdg.portal.enable = true; + xdg.portal.wlr.enable = true; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + nki.services.pam.enableGnomeKeyring = true; + services.input-remapper.enable = true; + services.swaylock.enable = true; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.11"; # Did you read the comment? + +} diff --git a/nki-x1c1/hardware-configuration.nix b/nki-x1c1/hardware-configuration.nix new file mode 100644 index 0000000..d20fa3c --- /dev/null +++ b/nki-x1c1/hardware-configuration.nix @@ -0,0 +1,41 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/bc8b0807-c3d6-4893-bcc2-02f059a51a80"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/885D-D058"; + fsType = "vfat"; + }; + + fileSystems."/home" = + { + device = "/dev/disk/by-uuid/a981870f-db1d-4441-81da-f1bab1ecc37c"; + fsType = "btrfs"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/2694d189-2ff6-4719-a449-367c52ed3ad6"; }]; + + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + hardware.opengl.enable = true; +}