diff --git a/.gitignore b/.gitignore index f18e503..aa10e55 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ result/ .DS_Store rust/target +*.qcow2 diff --git a/assets/wallpaper.jpg b/assets/wallpaper.jpg new file mode 100644 index 0000000..5cb1a5b Binary files /dev/null and b/assets/wallpaper.jpg differ diff --git a/desktop.qcow2 b/desktop.qcow2 new file mode 100644 index 0000000..fdf6ba6 Binary files /dev/null and b/desktop.qcow2 differ diff --git a/flake.lock b/flake.lock index 7eecfc5..b278631 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,73 @@ "type": "github" } }, + "base16": { + "inputs": { + "fromYaml": "fromYaml" + }, + "locked": { + "lastModified": 1746562888, + "narHash": "sha256-YgNJQyB5dQiwavdDFBMNKk1wyS77AtdgDk/VtU6wEaI=", + "owner": "SenchoPens", + "repo": "base16.nix", + "rev": "806a1777a5db2a1ef9d5d6f493ef2381047f2b89", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "base16.nix", + "type": "github" + } + }, + "base16-fish": { + "flake": false, + "locked": { + "lastModified": 1622559957, + "narHash": "sha256-PebymhVYbL8trDVVXxCvZgc0S5VxI7I1Hv4RMSquTpA=", + "owner": "tomyun", + "repo": "base16-fish", + "rev": "2f6dd973a9075dabccd26f1cded09508180bf5fe", + "type": "github" + }, + "original": { + "owner": "tomyun", + "repo": "base16-fish", + "type": "github" + } + }, + "base16-helix": { + "flake": false, + "locked": { + "lastModified": 1748408240, + "narHash": "sha256-9M2b1rMyMzJK0eusea0x3lyh3mu5nMeEDSc4RZkGm+g=", + "owner": "tinted-theming", + "repo": "base16-helix", + "rev": "6c711ab1a9db6f51e2f6887cc3345530b33e152e", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-helix", + "type": "github" + } + }, + "base16-vim": { + "flake": false, + "locked": { + "lastModified": 1732806396, + "narHash": "sha256-e0bpPySdJf0F68Ndanwm+KWHgQiZ0s7liLhvJSWDNsA=", + "owner": "tinted-theming", + "repo": "base16-vim", + "rev": "577fe8125d74ff456cf942c733a85d769afe58b7", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-vim", + "rev": "577fe8125d74ff456cf942c733a85d769afe58b7", + "type": "github" + } + }, "bats-assert": { "flake": false, "locked": { @@ -48,6 +115,30 @@ "type": "github" } }, + "cosmic-manager": { + "inputs": { + "flake-parts": "flake-parts", + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1744387566, + "narHash": "sha256-O39zTv7LdRgr4Hw38d+eQG2LYpP75rw2XKqTGV5qzgs=", + "owner": "HeitorAugustoLN", + "repo": "cosmic-manager", + "rev": "52d3fdd080a9dd4639948687682a68282fbf0314", + "type": "github" + }, + "original": { + "owner": "HeitorAugustoLN", + "repo": "cosmic-manager", + "type": "github" + } + }, "crane": { "locked": { "lastModified": 1751562746, @@ -70,11 +161,11 @@ ] }, "locked": { - "lastModified": 1751607816, - "narHash": "sha256-5PtrwjqCIJ4DKQhzYdm8RFePBuwb+yTzjV52wWoGSt4=", + "lastModified": 1751854533, + "narHash": "sha256-U/OQFplExOR1jazZY4KkaQkJqOl59xlh21HP9mI79Vc=", "owner": "nix-community", "repo": "disko", - "rev": "da6109c917b48abc1f76dd5c9bf3901c8c80f662", + "rev": "16b74a1e304197248a1bc663280f2548dbfcae3c", "type": "github" }, "original": { @@ -105,6 +196,22 @@ "type": "github" } }, + "firefox-gnome-theme": { + "flake": false, + "locked": { + "lastModified": 1748383148, + "narHash": "sha256-pGvD/RGuuPf/4oogsfeRaeMm6ipUIznI2QSILKjKzeA=", + "owner": "rafaelmardojai", + "repo": "firefox-gnome-theme", + "rev": "4eb2714fbed2b80e234312611a947d6cb7d70caf", + "type": "github" + }, + "original": { + "owner": "rafaelmardojai", + "repo": "firefox-gnome-theme", + "type": "github" + } + }, "flake-base": { "inputs": { "nixpkgs": [ @@ -144,6 +251,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "cosmic-manager", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nixos-anywhere", @@ -164,7 +292,28 @@ "type": "github" } }, - "flake-parts_2": { + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "stylix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1749398372, + "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_4": { "inputs": { "nixpkgs-lib": [ "terranix", @@ -252,6 +401,39 @@ "type": "github" } }, + "fromYaml": { + "flake": false, + "locked": { + "lastModified": 1731966426, + "narHash": "sha256-lq95WydhbUTWig/JpqiB7oViTcHFP8Lv41IGtayokA8=", + "owner": "SenchoPens", + "repo": "fromYaml", + "rev": "106af9e2f715e2d828df706c386a685698f3223b", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "fromYaml", + "type": "github" + } + }, + "gnome-shell": { + "flake": false, + "locked": { + "lastModified": 1744584021, + "narHash": "sha256-0RJ4mJzf+klKF4Fuoc8VN8dpQQtZnKksFmR2jhWE1Ew=", + "owner": "GNOME", + "repo": "gnome-shell", + "rev": "52c517c8f6c199a1d6f5118fae500ef69ea845ae", + "type": "github" + }, + "original": { + "owner": "GNOME", + "ref": "48.1", + "repo": "gnome-shell", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -297,7 +479,7 @@ "nixos-anywhere": { "inputs": { "disko": "disko_2", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "nix-vm-test": "nix-vm-test", "nixos-images": "nixos-images", "nixos-stable": "nixos-stable", @@ -364,11 +546,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1751582995, - "narHash": "sha256-u7ubvtxdTnFPpV27AHpgoKn7qHuE7sgWgza/1oj5nzA=", + "lastModified": 1751741127, + "narHash": "sha256-t75Shs76NgxjZSgvvZZ9qOmz5zuBE8buUaYD28BMTxg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7a732ed41ca0dd64b4b71b563ab9805a80a7d693", + "rev": "29e290002bfff26af1db6f64d070698019460302", "type": "github" }, "original": { @@ -393,9 +575,36 @@ "type": "github" } }, + "nur": { + "inputs": { + "flake-parts": [ + "stylix", + "flake-parts" + ], + "nixpkgs": [ + "stylix", + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix_3" + }, + "locked": { + "lastModified": 1751320053, + "narHash": "sha256-3m6RMw0FbbaUUa01PNaMLoO7D99aBClmY5ed9V3vz+0=", + "owner": "nix-community", + "repo": "NUR", + "rev": "cbde1735782f9c2bb2c63d5e05fba171a14a4670", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NUR", + "type": "github" + } + }, "root": { "inputs": { "advisory-db": "advisory-db", + "cosmic-manager": "cosmic-manager", "crane": "crane", "disko": "disko", "flake-base": "flake-base", @@ -403,6 +612,7 @@ "nixos-anywhere": "nixos-anywhere", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay", + "stylix": "stylix", "terranix": "terranix", "terranix-hcloud": "terranix-hcloud" } @@ -414,11 +624,11 @@ ] }, "locked": { - "lastModified": 1751769931, - "narHash": "sha256-QR2Rp/41NkA5YxcpvZEKD1S2QE1Pb9U415aK8M/4tJc=", + "lastModified": 1751942411, + "narHash": "sha256-01uMHCt2U9tP4f24DGch145tT8YQppLY5TC9mWK7O0A=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "3ac4f630e375177ea8317e22f5c804156de177e8", + "rev": "c587235f892930a61c9e415f0d9792a1b27a41a2", "type": "github" }, "original": { @@ -450,6 +660,41 @@ "type": "github" } }, + "stylix": { + "inputs": { + "base16": "base16", + "base16-fish": "base16-fish", + "base16-helix": "base16-helix", + "base16-vim": "base16-vim", + "firefox-gnome-theme": "firefox-gnome-theme", + "flake-parts": "flake-parts_3", + "gnome-shell": "gnome-shell", + "nixpkgs": [ + "nixpkgs" + ], + "nur": "nur", + "systems": "systems_2", + "tinted-foot": "tinted-foot", + "tinted-kitty": "tinted-kitty", + "tinted-schemes": "tinted-schemes", + "tinted-tmux": "tinted-tmux", + "tinted-zed": "tinted-zed" + }, + "locked": { + "lastModified": 1752009340, + "narHash": "sha256-6IKc+fdgJ+mWW8pBOVS5MYvttHBhvWSbff/31pG3SAY=", + "owner": "nix-community", + "repo": "stylix", + "rev": "c647aaa1dead3752fb49f226a4f67ae1030d7747", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-25.05", + "repo": "stylix", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -480,13 +725,28 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "terranix": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_4", "nixpkgs": [ "nixpkgs" ], - "systems": "systems_2" + "systems": "systems_3" }, "locked": { "lastModified": 1749381683, @@ -562,6 +822,87 @@ "type": "github" } }, + "tinted-foot": { + "flake": false, + "locked": { + "lastModified": 1726913040, + "narHash": "sha256-+eDZPkw7efMNUf3/Pv0EmsidqdwNJ1TaOum6k7lngDQ=", + "owner": "tinted-theming", + "repo": "tinted-foot", + "rev": "fd1b924b6c45c3e4465e8a849e67ea82933fcbe4", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "tinted-foot", + "rev": "fd1b924b6c45c3e4465e8a849e67ea82933fcbe4", + "type": "github" + } + }, + "tinted-kitty": { + "flake": false, + "locked": { + "lastModified": 1735730497, + "narHash": "sha256-4KtB+FiUzIeK/4aHCKce3V9HwRvYaxX+F1edUrfgzb8=", + "owner": "tinted-theming", + "repo": "tinted-kitty", + "rev": "de6f888497f2c6b2279361bfc790f164bfd0f3fa", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "tinted-kitty", + "type": "github" + } + }, + "tinted-schemes": { + "flake": false, + "locked": { + "lastModified": 1750770351, + "narHash": "sha256-LI+BnRoFNRa2ffbe3dcuIRYAUcGklBx0+EcFxlHj0SY=", + "owner": "tinted-theming", + "repo": "schemes", + "rev": "5a775c6ffd6e6125947b393872cde95867d85a2a", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "schemes", + "type": "github" + } + }, + "tinted-tmux": { + "flake": false, + "locked": { + "lastModified": 1751159871, + "narHash": "sha256-UOHBN1fgHIEzvPmdNMHaDvdRMgLmEJh2hNmDrp3d3LE=", + "owner": "tinted-theming", + "repo": "tinted-tmux", + "rev": "bded5e24407cec9d01bd47a317d15b9223a1546c", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "tinted-tmux", + "type": "github" + } + }, + "tinted-zed": { + "flake": false, + "locked": { + "lastModified": 1751158968, + "narHash": "sha256-ksOyv7D3SRRtebpXxgpG4TK8gZSKFc4TIZpR+C98jX8=", + "owner": "tinted-theming", + "repo": "base16-zed", + "rev": "86a470d94204f7652b906ab0d378e4231a5b3384", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-zed", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -603,6 +944,28 @@ "repo": "treefmt-nix", "type": "github" } + }, + "treefmt-nix_3": { + "inputs": { + "nixpkgs": [ + "stylix", + "nur", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733222881, + "narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "49717b5af6f80172275d47a418c9719a31a78b53", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b0f6305..afa64e3 100644 --- a/flake.nix +++ b/flake.nix @@ -40,6 +40,19 @@ nixpkgs.follows = "nixpkgs"; }; }; + stylix = { + url = "github:nix-community/stylix/release-25.05"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + cosmic-manager = { + url = "github:HeitorAugustoLN/cosmic-manager"; + inputs = { + nixpkgs.follows = "nixpkgs"; + home-manager.follows = "home-manager"; + }; + }; }; outputs = @@ -52,15 +65,28 @@ dirs = inputs.nixpkgs.lib.filterAttrs (name: kind: kind == "directory") files; in builtins.attrNames dirs; - profileArgs = { inherit self; }; - profileNames = dirsInPath ./nix/profiles; nixosModules = dirsInPath ./nix/modules/nixos; - inputModules = [ inputs.disko.nixosModules.disko ]; + homeModules = dirsInPath ./nix/modules/home; + inputNixosModules = [ + inputs.disko.nixosModules.disko + inputs.stylix.nixosModules.stylix + ]; + inputHomeModules = [ + inputs.cosmic-manager.homeManagerModules.cosmic-manager + ]; + allowUnfreePackages = [ + "spotify" + "google-chrome" + ]; in (inputs.flake-base.lib.mkFlake { inherit inputs; src = ./.; - systems.modules.nixos = inputModules; + channels-config = { + allowUnfreePredicate = pkg: builtins.elem (inputs.nixpkgs.lib.getName pkg) allowUnfreePackages; + }; + systems.modules.nixos = inputNixosModules; + homes.modules = inputHomeModules; snowfall = { root = ./nix; namespace = "khscodes"; @@ -69,17 +95,17 @@ name = "Machines"; }; }; - modules.nixos = { - default = - { - imports = builtins.map (m: self.nixosModules.${m}) nixosModules ++ inputModules; - } - // (builtins.listToAttrs ( - builtins.map (n: { - name = n; - value = (import ./nix/profiles/${n} profileArgs); - }) profileNames - )); + modules = { + nixos = { + default = { + imports = (builtins.map (m: self.nixosModules.${m}) nixosModules) ++ inputNixosModules; + }; + }; + home = { + default = { + imports = (builtins.map (m: self.homeModules.${m}) homeModules) ++ inputHomeModules; + }; + }; }; overlays = [ inputs.rust-overlay.overlays.default ]; }) diff --git a/nix/homes/x86_64-linux/khs@desktop.kaareskovgaard.net/default.nix b/nix/homes/x86_64-linux/khs@desktop.kaareskovgaard.net/default.nix new file mode 100644 index 0000000..e607c02 --- /dev/null +++ b/nix/homes/x86_64-linux/khs@desktop.kaareskovgaard.net/default.nix @@ -0,0 +1,4 @@ +{ inputs, ... }: +{ + imports = [ "${inputs.self}/nix/profiles/home/khs-linux-desktop.nix" ]; +} diff --git a/nix/homes/x86_64-linux/khs@test.kaareskovgaard.net/default.nix b/nix/homes/x86_64-linux/khs@test.kaareskovgaard.net/default.nix deleted file mode 100644 index 740142d..0000000 --- a/nix/homes/x86_64-linux/khs@test.kaareskovgaard.net/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - snowfallorg.user.name = "khs"; - home.stateVersion = "25.05"; -} diff --git a/nix/modules/home/applications/default.nix b/nix/modules/home/applications/default.nix new file mode 100644 index 0000000..c915eb0 --- /dev/null +++ b/nix/modules/home/applications/default.nix @@ -0,0 +1 @@ +{ ... }: { } diff --git a/nix/modules/home/desktop/default.nix b/nix/modules/home/desktop/default.nix new file mode 100644 index 0000000..245f4b5 --- /dev/null +++ b/nix/modules/home/desktop/default.nix @@ -0,0 +1,6 @@ +{ lib, ... }: +{ + options.khscodes.desktop = { + enable = lib.mkEnableOption "Generic setting other modules can use to enable/disable stuff when used on desktops"; + }; +} diff --git a/nix/modules/home/khs/applications/alacritty/default.nix b/nix/modules/home/khs/applications/alacritty/default.nix new file mode 100644 index 0000000..7f66990 --- /dev/null +++ b/nix/modules/home/khs/applications/alacritty/default.nix @@ -0,0 +1,113 @@ +{ + lib, + pkgs, + config, + system, + ... +}: +let + isDarwin = lib.strings.hasSuffix "-darwin" system; + isLinux = lib.strings.hasSuffix "-darwin" system; + shell = pkgs.bashInteractive; + shellArgs = [ + "-c" + (lib.getExe pkgs.zellij) + ]; +in +{ + config = lib.mkIf (config.khscodes.khs.enable && config.khscodes.desktop.enable) { + programs.alacritty = { + enable = true; + settings = { + terminal = + { + shell = { + program = "${shell}${shell.shellPath}"; + args = shellArgs; + }; + } + // lib.attrsets.optionalAttrs isDarwin { + osc52 = "CopyPaste"; + }; + scrolling = { + history = 100000; + }; + window = { + padding = { + x = 2; + y = 0; + }; + }; + bell = { + animation = "EaseOutExpo"; + }; + hints = { + enabled = [ + { + regex = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\\u0000-\\u001F\\u007F-\\u009F<>\"\\\\s{-}\\\\^⟨⟩`]+"; + command = if isLinux then "xdg-open" else "open"; + post_processing = true; + mouse = { + enabled = true; + mods = "Control"; + }; + } + ]; + }; + window = { + option_as_alt = "OnlyLeft"; + }; + env = { + TERM = "xterm-256color"; + }; + keyboard.bindings = + [ + { + key = "T"; + mods = "Control|Shift"; + action = "SpawnNewInstance"; + } + { + key = "W"; + mods = "Control|Shift"; + action = "Quit"; + } + { + key = "Plus"; + mods = "Control"; + action = "IncreaseFontSize"; + } + { + key = "Minus"; + mods = "Control"; + action = "DecreaseFontSize"; + } + { + key = "Key0"; + mods = "Control"; + action = "ResetFontSize"; + } + { + key = "C"; + mods = "Super"; + action = "None"; + } + ] + ++ lib.lists.optionals isDarwin [ + { + key = "N"; + mods = "Command"; + action = "SpawnNewInstance"; + } + # Allow zellij to receive the keys, to make copy/pasting work in darwin + { + key = "C"; + mods = "Command"; + action = "ReceiveChar"; + } + ]; + }; + }; + stylix.targets.alacritty.enable = true; + }; +} diff --git a/nix/modules/home/khs/applications/default.nix b/nix/modules/home/khs/applications/default.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/nix/modules/home/khs/applications/default.nix @@ -0,0 +1 @@ +{ } diff --git a/nix/modules/home/khs/default.nix b/nix/modules/home/khs/default.nix new file mode 100644 index 0000000..16400e2 --- /dev/null +++ b/nix/modules/home/khs/default.nix @@ -0,0 +1,17 @@ +{ lib, config, ... }: +let + cfg = config.khscodes.khs; +in +{ + options.khscodes.khs = { + enable = lib.mkEnableOption "Enables the settings for KHS"; + }; + + config = lib.mkIf cfg.enable { + snowfallorg.user.name = "khs"; + home.sessionVariables = { + EMAIL = "kaare@kaareskovgaard.net"; + }; + home.stateVersion = "25.05"; + }; +} diff --git a/nix/modules/home/khs/desktop/cosmic/default.nix b/nix/modules/home/khs/desktop/cosmic/default.nix new file mode 100644 index 0000000..e6ee668 --- /dev/null +++ b/nix/modules/home/khs/desktop/cosmic/default.nix @@ -0,0 +1,120 @@ +{ + config, + inputs, + lib, + ... +}: +let + cosmicLib = import "${inputs.cosmic-manager}/lib" { inherit lib; }; + mkRON = cosmicLib.mkRON; + accent = mkRON "optional" { + red = mkRON "raw" "0.3882353"; + green = mkRON "raw" "0.8156863"; + blue = mkRON "raw" "0.8745098"; + }; + active_hint = 1; + corner_radii = { + radius_0 = mkRON "tuple" [ + 0.0 + 0.0 + 0.0 + 0.0 + ]; + radius_xs = mkRON "tuple" [ + 2.0 + 2.0 + 2.0 + 2.0 + ]; + radius_s = mkRON "tuple" [ + 8.0 + 8.0 + 8.0 + 8.0 + ]; + radius_m = mkRON "tuple" [ + 8.0 + 8.0 + 8.0 + 8.0 + ]; + radius_l = mkRON "tuple" [ + 8.0 + 8.0 + 8.0 + 8.0 + ]; + radius_xl = mkRON "tuple" [ + 8.0 + 8.0 + 8.0 + 8.0 + ]; + }; + gaps = mkRON "tuple" [ + 0 + 1 + ]; +in +{ + config = lib.mkIf (config.khscodes.desktop.enable && config.khscodes.khs.enable) { + wayland.desktopManager.cosmic = { + enable = true; + applets = { + # This is the "dock" + app-list = { + settings = { + enable_drag_source = false; + favorites = [ + "com.system76.CosmicFiles" + "thunderbird" + "Google-chrome" + "Code" + "Alacritty" + "com.system76.CosmicSettings" + "Spotify" + "steam" + ]; + filter_top_levels = mkRON "optional" null; + }; + }; + }; + appearance = { + toolkit = { + interface_density = mkRON "enum" "Standard"; + monospace_font = { + family = config.stylix.fonts.monospace.name; + stretch = mkRON "enum" "Normal"; + style = mkRON "enum" "Normal"; + weight = mkRON "enum" "Normal"; + }; + }; + theme = { + light = { + inherit + accent + active_hint + corner_radii + gaps + ; + }; + dark = { + inherit + accent + active_hint + corner_radii + gaps + ; + }; + }; + }; + compositor = { + active_hint = true; + autotile = true; + autotile_behavior = mkRON "enum" "PerWorkspace"; + cursor_follows_focus = false; + focus_follows_cursor = false; + }; + }; + }; +} diff --git a/nix/modules/home/khs/shell/bash/default.nix b/nix/modules/home/khs/shell/bash/default.nix new file mode 100644 index 0000000..a711dc4 --- /dev/null +++ b/nix/modules/home/khs/shell/bash/default.nix @@ -0,0 +1,9 @@ +{ config, lib, ... }: +{ + config = lib.mkIf config.khscodes.khs.enable { + programs.bash = { + enable = true; + shellAliases = config.khscodes.khs.shell.aliases; + }; + }; +} diff --git a/nix/modules/home/khs/shell/carapace/default.nix b/nix/modules/home/khs/shell/carapace/default.nix new file mode 100644 index 0000000..c2af0bd --- /dev/null +++ b/nix/modules/home/khs/shell/carapace/default.nix @@ -0,0 +1,12 @@ +{ lib, config, ... }: +{ + config = lib.mkIf (config.khscodes.khs.enable && config.khscodes.desktop.enable) { + programs.carapace = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + enableFishIntegration = true; + enableNushellIntegration = true; + }; + }; +} diff --git a/nix/modules/home/khs/shell/default.nix b/nix/modules/home/khs/shell/default.nix new file mode 100644 index 0000000..05c1cf4 --- /dev/null +++ b/nix/modules/home/khs/shell/default.nix @@ -0,0 +1,18 @@ +{ lib, ... }: +{ + options.khscodes.khs.shell = { + aliases = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + description = "Shell aliases to be copied to different shells"; + default = { + add = "git add"; + commit = "git commit"; + st = "git status"; + push = "git push"; + puff = "git puff"; + pull = "git pull"; + purr = "git purr"; + }; + }; + }; +} diff --git a/nix/modules/home/khs/shell/fish/default.nix b/nix/modules/home/khs/shell/fish/default.nix new file mode 100644 index 0000000..ea46533 --- /dev/null +++ b/nix/modules/home/khs/shell/fish/default.nix @@ -0,0 +1,10 @@ +{ config, lib, ... }: +{ + config = lib.mkIf config.khscodes.khs.enable { + programs.fish = { + enable = true; + shellAliases = config.khscodes.khs.shell.aliases; + shellInit = "set fish_greeting"; + }; + }; +} diff --git a/nix/modules/home/khs/shell/nushell/default.nix b/nix/modules/home/khs/shell/nushell/default.nix new file mode 100644 index 0000000..8069729 --- /dev/null +++ b/nix/modules/home/khs/shell/nushell/default.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + pkgs, + ... +}: +let + aliases = config.khscodes.khs.shell.aliases; +in +{ + config = lib.mkIf config.khscodes.khs.enable { + programs.nushell = { + enable = true; + shellAliases = aliases; + extraConfig = '' + $env.config = { + show_banner: false + } + ''; + environmentVariables = config.home.sessionVariables; + }; + }; +} diff --git a/nix/modules/home/khs/shell/oh-my-posh/default.nix b/nix/modules/home/khs/shell/oh-my-posh/default.nix new file mode 100644 index 0000000..c181680 --- /dev/null +++ b/nix/modules/home/khs/shell/oh-my-posh/default.nix @@ -0,0 +1,158 @@ +{ config, lib, ... }: +let + cfg = config.khscodes.khs.shell.oh-my-posh; + unicodeChar = code: builtins.fromJSON ''"\u${code}"''; + powerline_symbol = unicodeChar "e0b0"; + rpowerline_symbol = unicodeChar "e0b2"; + colors = config.lib.stylix.colors.withHashtag; + bright-yellow = config.lib.stylix.colors.yellow or config.lib.stylix.colors.base0a; + bright-yellow-hashtag = "#${bright-yellow}"; + segment_style = { + style = "diamond"; + leading_diamond = ""; + trailing_diamond = powerline_symbol; + }; + rsegment_style = { + style = "diamond"; + leading_diamond = rpowerline_symbol; + trailing_diamond = ""; + }; +in +{ + options.khscodes.khs.shell.oh-my-posh = { + enable = lib.mkEnableOption "Enables oh my posh khs setup"; + }; + config = lib.mkIf cfg.enable { + programs.oh-my-posh = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + enableFishIntegration = true; + enableNushellIntegration = true; + useTheme = null; + settings = { + "$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"; + "console_title_template" = "{{ .PWD }} @ {{ .HostName }}"; + "blocks" = [ + { + "alignment" = "left"; + "type" = "prompt"; + "segments" = [ + { + type = "shell"; + style = "diamond"; + leading_diamond = ""; + trailing_diamond = powerline_symbol; + "template" = "{{ .Name }}"; + "background" = colors.base00; + "foreground" = colors.blue; + "background_templates" = [ "{{ if eq .Name \"🐠\" }}${colors.base00}{{ end }}" ]; + properties = { + mapped_shell_names = { + "nushell" = "nu"; + "fish" = "🐟"; + "bash" = "$_"; + "zsh" = "%_"; + }; + }; + } + ( + { + "type" = "session"; + "background" = colors.red; + "foreground" = colors.base07; + "template" = "{{ if .SSHSession }} {{ .HostName }} {{ end }}"; + } + // segment_style + ) + ( + { + "type" = "path"; + "background" = colors.blue; + "foreground" = colors.base00; + "template" = " {{ .Path }} "; + "properties" = { + "style" = "full"; + }; + } + // segment_style + ) + ( + { + "type" = "git"; + "background" = colors.green; + "foreground" = colors.base00; + "background_templates" = [ + "{{ if or (.Working.Changed) (.Staging.Changed) }}${colors.yellow}{{ end }}" + ]; + "template" = + "{{ if .Detached }}➦ {{ trunc 7 .Commit.Sha }}{{ else }}{{ .UpstreamIcon }} {{ .Ref }}{{ end }}{{ if .Merge }}|merge{{ end }}{{ if .Rebase }}|rebase{{ end }}{{ if .CherryPick }}|cherrypick{{ end }}{{ if .Ahead}}↑{{ .Ahead }}{{ end }}{{ if .Behind }}↓{{ .Behind }}{{ end }}{{ if .Working.Changed}}●{{ end }}{{ if .Staging.Changed }}✚{{ end }}{{ if .StashCount }} 󰺿{{ end }} "; + "properties" = { + "fetch_status" = true; + "untracked_modes" = { + "/Users/user/Projects/oh-my-posh/" = "no"; + }; + fetch_upstream_icon = true; + upstream = { + git_icon = ""; + }; + "source" = "cli"; + }; + } + // segment_style + ) + ]; + } + { + alignment = "right"; + type = "rprompt"; + "segments" = [ + ( + { + type = "status"; + background = colors.base01; + background_templates = [ "{{ if .Error }}${colors.red}{{ end }}" ]; + foreground = colors.green; + foreground_templates = [ "{{ if .Error}}${bright-yellow-hashtag}{{ end }}" ]; + template = " {{ if .Error }}✘ {{ .Code }}{{ else }}✔{{ end }} "; + properties = { + always_enabled = true; + }; + } + // rsegment_style + ) + ( + { + type = "executiontime"; + foreground = colors.base00; + background = colors.yellow; + template = " ⌚{{ .FormattedMs }} "; + properties = { + always_enabled = false; + threshold = 3000; + style = "round"; + }; + } + // rsegment_style + ) + # Rendering this screws up spacing of the beginning of the prompt + ( + { + type = "nix-shell"; + background = colors.blue; + foreground = colors.base00; + template = " {{ .Type }} "; + } + // rsegment_style + ) + ]; + } + ]; + "terminal_background" = colors.base00; + "disable_notice" = true; + "final_space" = true; + "version" = 2; + }; + }; + }; +} diff --git a/nix/modules/home/khs/shell/zellij/default.nix b/nix/modules/home/khs/shell/zellij/default.nix new file mode 100644 index 0000000..d5bf5fe --- /dev/null +++ b/nix/modules/home/khs/shell/zellij/default.nix @@ -0,0 +1,505 @@ +{ + lib, + config, + pkgs, + system, + ... +}: +let + isDarwin = lib.strings.hasSuffix "-darwin" system; +in +{ + config = lib.mkIf (config.khscodes.khs.enable && config.khscodes.desktop.enable) { + # In built styles look off to me. And when alacritty is themed, + # this appears to not be needed. + stylix.targets.zellij.enable = false; + programs.zellij = { + enable = true; + settings = { + default_shell = lib.getExe pkgs.fish; + copy_on_select = false; + mouse_mode = true; + show_startup_tips = false; + scroll_buffer_size = 100000; + support_kitty_keyboard_protocol = true; + "keybinds clear-defaults=true" = { + normal = lib.attrsets.optionalAttrs isDarwin { + "bind \"Super c\"" = { + Copy = [ ]; + }; + }; + locked = { + "bind \"Ctrl g\"" = { + SwitchToMode = "Normal"; + }; + }; + resize = { + "bind \"Ctrl n\"" = { + SwitchToMode = "Normal"; + }; + "bind \"h\" \"Left\"" = { + Resize = "Increase Left"; + }; + "bind \"j\" \"Down\"" = { + Resize = "Increase Down"; + }; + "bind \"k\" \"Up\"" = { + Resize = "Increase Up"; + }; + "bind \"l\" \"Right\"" = { + Resize = "Increase Right"; + }; + "bind \"H\"" = { + Resize = "Decrease Left"; + }; + "bind \"J\"" = { + Resize = "Decrease Down"; + }; + "bind \"K\"" = { + Resize = "Decrease Up"; + }; + "bind \"L\"" = { + Resize = "Decrease Right"; + }; + "bind \"=\" \"+\"" = { + Resize = "Increase"; + }; + "bind \"-\"" = { + Resize = "Decrease"; + }; + }; + pane = { + "bind \"Ctrl\ p\"" = { + SwitchToMode = "Normal"; + }; + "bind \"h\" \"Left\"" = { + MoveFocus = "Left"; + }; + "bind \"l\" \"Right\"" = { + MoveFocus = "Right"; + }; + "bind \"j\" \"Down\"" = { + MoveFocus = "Down"; + }; + "bind \"k\" \"Up\"" = { + MoveFocus = "Up"; + }; + "bind \"p\"" = { + SwitchFocus = [ ]; + }; + "bind \"n\"" = { + NewPane = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"d\"" = { + NewPane = "Down"; + SwitchToMode = "Normal"; + }; + "bind \"r\"" = { + NewPane = "Right"; + SwitchToMode = "Normal"; + }; + "bind \"x\"" = { + CloseFocus = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"f\"" = { + ToggleFocusFullscreen = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"z\"" = { + TogglePaneFrames = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"w\"" = { + ToggleFloatingPanes = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"e\"" = { + TogglePaneEmbedOrFloating = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"c\"" = { + SwitchToMode = "RenamePane"; + PaneNameInput = 0; + }; + }; + move = { + "bind \"Ctrl h\"" = { + SwitchToMode = "Normal"; + }; + "bind \"n\" \"Tab\"" = { + MovePane = [ ]; + }; + "bind \"p\"" = { + MovePaneBackwards = [ ]; + }; + "bind \"h\" \"Left\"" = { + MovePane = "Left"; + }; + "bind \"j\" \"Down\"" = { + MovePane = "Down"; + }; + "bind \"k\" \"Up\"" = { + MovePane = "Up"; + }; + "bind \"l\" \"Right\"" = { + MovePane = "Right"; + }; + }; + tab = { + "bind \"Alt t\"" = { + SwitchToMode = "Normal"; + }; + "bind \"r\"" = { + SwitchToMode = "RenameTab"; + TabNameInput = 0; + }; + "bind \"h\" \"Left\" \"Up\" \"k\"" = { + GoToPreviousTab = [ ]; + }; + "bind \"l\" \"Right\" \"Down\" \"j\"" = { + GoToNextTab = [ ]; + }; + "bind \"n\"" = { + NewTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"x\"" = { + CloseTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"s\"" = { + ToggleActiveSyncTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"1\"" = { + GoToTab = 1; + SwitchToMode = "Normal"; + }; + "bind \"2\"" = { + GoToTab = 2; + SwitchToMode = "Normal"; + }; + "bind \"3\"" = { + GoToTab = 3; + SwitchToMode = "Normal"; + }; + "bind \"4\"" = { + GoToTab = 4; + SwitchToMode = "Normal"; + }; + "bind \"5\"" = { + GoToTab = 5; + SwitchToMode = "Normal"; + }; + "bind \"6\"" = { + GoToTab = 6; + SwitchToMode = "Normal"; + }; + "bind \"7\"" = { + GoToTab = 7; + SwitchToMode = "Normal"; + }; + "bind \"8\"" = { + GoToTab = 8; + SwitchToMode = "Normal"; + }; + "bind \"9\"" = { + GoToTab = 9; + SwitchToMode = "Normal"; + }; + "bind \"Tab\"" = { + ToggleTab = [ ]; + }; + }; + scroll = { + "bind \"Ctrl s\"" = { + SwitchToMode = "Normal"; + }; + "bind \"e\"" = { + EditScrollback = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"s\"" = { + SwitchToMode = "EnterSearch"; + SearchInput = 0; + }; + "bind \"Ctrl c\"" = { + ScrollToBottom = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"j\" \"Down\"" = { + ScrollDown = [ ]; + }; + "bind \"k\" \"Up\"" = { + ScrollUp = [ ]; + }; + "bind \"Ctrl f\" \"PageDown\" \"Right\" \"l\"" = { + PageScrollDown = [ ]; + }; + "bind \"Ctrl b\" \"PageUp\" \"Left\" \"h\"" = { + PageScrollUp = [ ]; + }; + "bind \"d\"" = { + HalfPageScrollDown = [ ]; + }; + "bind \"u\"" = { + HalfPageScrollUp = [ ]; + }; + }; + search = { + "bind \"Ctrl s\"" = { + SwitchToMode = "Normal"; + }; + "bind \"Ctrl c\"" = { + ScrollToBottom = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"j\" \"Down\"" = { + ScrollDown = [ ]; + }; + "bind \"k\" \"Up\"" = { + ScrollUp = [ ]; + }; + "bind \"Ctrl f\" \"PageDown\" \"Right\" \"l\"" = { + PageScrollDown = [ ]; + }; + "bind \"Ctrl b\" \"PageUp\" \"Left\" \"h\"" = { + PageScrollUp = [ ]; + }; + "bind \"d\"" = { + HalfPageScrollDown = [ ]; + }; + "bind \"u\"" = { + HalfPageScrollUp = [ ]; + }; + "bind \"n\"" = { + Search = "down"; + }; + "bind \"p\"" = { + Search = "up"; + }; + "bind \"c\"" = { + SearchToggleOption = "CaseSensitivity"; + }; + "bind \"w\"" = { + SearchToggleOption = "Wrap"; + }; + "bind \"o\"" = { + SearchToggleOption = "WholeWord"; + }; + }; + entersearch = { + "bind \"Ctrl c\" \"Esc\"" = { + SwitchToMode = "Scroll"; + }; + "bind \"Enter\"" = { + SwitchToMode = "Search"; + }; + }; + renametab = { + "bind \"Ctrl c\"" = { + SwitchToMode = "Normal"; + }; + "bind \"Esc\"" = { + UndoRenameTab = [ ]; + SwitchToMode = "Tab"; + }; + }; + renamepane = { + "bind \"Ctrl c\"" = { + SwitchToMode = "Normal"; + }; + "bind \"Esc\"" = { + UndoRenamePane = [ ]; + SwitchToMode = "Pane"; + }; + }; + session = { + "unbind \"Ctrl o\"" = [ ]; + "bind \"Ctrl q\"" = { + SwitchToMode = "Normal"; + }; + "bind \"Ctrl s\"" = { + SwitchToMode = "Scroll"; + }; + "bind \"d\"" = { + Detach = [ ]; + }; + }; + tmux = { + "bind \"[\"" = { + SwitchToMode = "Scroll"; + }; + "bind \"Ctrl b\"" = { + Write = 2; + SwitchToMode = "Normal"; + }; + "bind \"\\\"\"" = { + NewPane = "Down"; + SwitchToMode = "Normal"; + }; + "bind \"%\"" = { + NewPane = "Right"; + SwitchToMode = "Normal"; + }; + "bind \"z\"" = { + ToggleFocusFullscreen = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"c\"" = { + NewTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \",\"" = { + SwitchToMode = "RenameTab"; + }; + "bind \"p\"" = { + GoToPreviousTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"n\"" = { + GoToNextTab = [ ]; + SwitchToMode = "Normal"; + }; + "bind \"Left\"" = { + MoveFocus = "Left"; + SwitchToMode = "Normal"; + }; + "bind \"Right\"" = { + MoveFocus = "Right"; + SwitchToMode = "Normal"; + }; + "bind \"Down\"" = { + MoveFocus = "Down"; + SwitchToMode = "Normal"; + }; + "bind \"Up\"" = { + MoveFocus = "Up"; + SwitchToMode = "Normal"; + }; + "bind \"h\"" = { + MoveFocus = "Left"; + SwitchToMode = "Normal"; + }; + "bind \"l\"" = { + MoveFocus = "Right"; + SwitchToMode = "Normal"; + }; + "bind \"j\"" = { + MoveFocus = "Down"; + SwitchToMode = "Normal"; + }; + "bind \"k\"" = { + MoveFocus = "Up"; + SwitchToMode = "Normal"; + }; + "bind \"o\"" = { + FocusNextPane = [ ]; + }; + "bind \"d\"" = { + Detach = [ ]; + }; + "bind \"Space\"" = { + NextSwapLayout = [ ]; + }; + "bind \"x\"" = { + CloseFocus = [ ]; + SwitchToMode = "Normal"; + }; + }; + "shared_except \"locked\"" = { + "bind \"Ctrl g\"" = { + SwitchToMode = "Locked"; + }; + "bind \"Alt n\"" = { + NewPane = [ ]; + }; + "bind \"Alt h\" \"Alt Left\"" = { + MoveFocusOrTab = "Left"; + }; + "bind \"Alt l\" \"Alt Right\"" = { + MoveFocusOrTab = "Right"; + }; + "bind \"Alt j\" \"Alt Down\"" = { + MoveFocus = "Down"; + }; + "bind \"Alt k\" \"Alt Up\"" = { + MoveFocus = "Up"; + }; + "bind \"Alt =\" \"Alt +\"" = { + Resize = "Increase"; + }; + "bind \"Alt -\"" = { + Resize = "Decrease"; + }; + "bind \"Alt [\"" = { + PreviousSwapLayout = [ ]; + }; + "bind \"Alt ]\"" = { + NextSwapLayout = [ ]; + }; + }; + "shared_except \"normal\" \"locked\"" = { + "bind \"Enter\" \"Esc\"" = { + SwitchToMode = "Normal"; + }; + }; + "shared_except \"pane\" \"locked\"" = { + "bind \"Ctrl p\"" = { + SwitchToMode = "Pane"; + }; + }; + "shared_except \"resize\" \"locked\"" = { + "bind \"Ctrl n\"" = { + SwitchToMode = "Resize"; + }; + }; + "shared_except \"scroll\" \"locked\"" = { + "bind \"Ctrl s\"" = { + SwitchToMode = "Scroll"; + }; + }; + "shared_except \"session\" \"locked\"" = { + unbind = "Ctrl o"; + "bind \"Ctrl q\"" = { + SwitchToMode = "Session"; + }; + }; + "shared_except \"tab\" \"locked\"" = { + "bind \"Alt t\"" = { + SwitchToMode = "Tab"; + }; + }; + "shared_except \"move\" \"locked\"" = { + "bind \"Ctrl h\"" = { + SwitchToMode = "Move"; + }; + }; + "shared_except \"tmux\" \"locked\"" = { + "bind \"Ctrl b\"" = { + SwitchToMode = "Tmux"; + }; + }; + }; + plugins = { + tab-bar = { + path = "tab-bar"; + }; + status-bar = { + path = "status-bar"; + }; + strider = { + path = "strider"; + }; + compact-bar = { + path = "compact-bar"; + }; + }; + simplified-ui = false; + pane_frames = false; + }; + }; + }; +} diff --git a/nix/modules/home/khs/shell/zsh/default.nix b/nix/modules/home/khs/shell/zsh/default.nix new file mode 100644 index 0000000..1800055 --- /dev/null +++ b/nix/modules/home/khs/shell/zsh/default.nix @@ -0,0 +1,9 @@ +{ config, lib, ... }: +{ + config = lib.mkIf config.khscodes.khs.enable { + programs.zsh = { + enable = true; + shellAliases = config.khscodes.khs.shell.aliases; + }; + }; +} diff --git a/nix/modules/nixos/infrastructure/hetzner-instance/default.nix b/nix/modules/nixos/infrastructure/hetzner-instance/default.nix index 27f9670..d65e044 100644 --- a/nix/modules/nixos/infrastructure/hetzner-instance/default.nix +++ b/nix/modules/nixos/infrastructure/hetzner-instance/default.nix @@ -6,7 +6,7 @@ }: let cfg = config.khscodes.infrastructure.hetzner-instance; - fqdn = config.khscodes.fqdn; + fqdn = config.khscodes.networking.fqdn; firewallTcpRules = lib.lists.map (p: { direction = "in"; protocol = "tcp"; @@ -205,8 +205,8 @@ in { assertions = [ { - assertion = config.khscodes.fqdn != null; - message = "Must set config.khscodes.fqdn when using opentofu"; + assertion = config.khscodes.networking.fqdn != null; + message = "Must set config.khscodes.networking.fqdn when using opentofu"; } ]; diff --git a/nix/modules/nixos/infrastructure/khs-openstack-instance/default.nix b/nix/modules/nixos/infrastructure/khs-openstack-instance/default.nix index 110b669..4478c81 100644 --- a/nix/modules/nixos/infrastructure/khs-openstack-instance/default.nix +++ b/nix/modules/nixos/infrastructure/khs-openstack-instance/default.nix @@ -6,7 +6,7 @@ }: let cfg = config.khscodes.infrastructure.khs-openstack-instance; - fqdn = config.khscodes.fqdn; + fqdn = config.khscodes.networking.fqdn; firewallTcpRules = lib.lists.flatten ( lib.lists.map (p: [ { @@ -232,8 +232,8 @@ in { assertions = [ { - assertion = config.khscodes.fqdn != null; - message = "Must set config.khscodes.fqdn when using opentofu"; + assertion = config.khscodes.networking.fqdn != null; + message = "Must set config.khscodes.networking.fqdn when using opentofu"; } ]; diff --git a/nix/modules/nixos/networking/default.nix b/nix/modules/nixos/networking/default.nix new file mode 100644 index 0000000..c915eb0 --- /dev/null +++ b/nix/modules/nixos/networking/default.nix @@ -0,0 +1 @@ +{ ... }: { } diff --git a/nix/modules/nixos/fqdn/default.nix b/nix/modules/nixos/networking/fqdn/default.nix similarity index 86% rename from nix/modules/nixos/fqdn/default.nix rename to nix/modules/nixos/networking/fqdn/default.nix index 73cf099..bc185cc 100644 --- a/nix/modules/nixos/fqdn/default.nix +++ b/nix/modules/nixos/networking/fqdn/default.nix @@ -4,10 +4,10 @@ ... }: let - cfg = config.khscodes.fqdn; + cfg = config.khscodes.networking.fqdn; in { - options.khscodes.fqdn = lib.mkOption { + options.khscodes.networking.fqdn = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; description = "Sets the FQDN of the machine. This is a prerequisite for many modules to be used"; diff --git a/nix/modules/nixos/security/default.nix b/nix/modules/nixos/security/default.nix new file mode 100644 index 0000000..c915eb0 --- /dev/null +++ b/nix/modules/nixos/security/default.nix @@ -0,0 +1 @@ +{ ... }: { } diff --git a/nix/modules/nixos/security/yubikey/default.nix b/nix/modules/nixos/security/yubikey/default.nix new file mode 100644 index 0000000..889c91e --- /dev/null +++ b/nix/modules/nixos/security/yubikey/default.nix @@ -0,0 +1,31 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.khscodes.security.yubikey; +in +{ + options.khscodes.security.yubikey = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + }; + }; + config = lib.mkIf cfg.enable { + services.pcscd.enable = true; + services.udev.packages = [ pkgs.yubikey-personalization ]; + + environment.systemPackages = [ + pkgs.yubikey-manager + pkgs.yubico-piv-tool + ]; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + }; +} diff --git a/nix/modules/nixos/users/default.nix b/nix/modules/nixos/users/default.nix new file mode 100644 index 0000000..c915eb0 --- /dev/null +++ b/nix/modules/nixos/users/default.nix @@ -0,0 +1 @@ +{ ... }: { } diff --git a/nix/modules/nixos/users/khs/default.nix b/nix/modules/nixos/users/khs/default.nix new file mode 100644 index 0000000..527be3e --- /dev/null +++ b/nix/modules/nixos/users/khs/default.nix @@ -0,0 +1,21 @@ +{ lib, config, ... }: +let + cfg = config.khscodes.users.khs; +in +{ + options.khscodes.users.khs = { + enable = lib.mkEnableOption "Enables settings for the khs user. This should be used in conjunction with homes"; + }; + + config = lib.mkIf cfg.enable { + snowfallorg.users.khs.admin = true; + users.users.khs = { + # TODO: What should I do wrt. ensuring the passwords are consistent? + # Maybe set them through OpenBAO and some service? + initialPassword = "changeme"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqY0FHnWFKfLG2yfgr4qka5sR9CK+EMAhzlHUkaQyWHTKD+G0/vC/fNPyL1VV3Dxc/ajxGuPzVE+mBMoyxazL3EtuCDOVvHJ5CR+MUSEckg/DDwcGHqy6rC8BvVVpTAVL04ByQdwFnpE1qNSBaQLkxaFVdtriGKkgMkc7+UNeYX/bv7yn+APqfP1a3xr6wdkSSdO8x4N2jsSygOIMx10hLyCV4Ueu7Kp8Ww4rGY8j5o7lKJhbgfItBfSOuQHdppHVF/GKYRhdnK6Y2fZVYbhq4KipUtclbZ6O/VYd8/sOO98+LMm7cOX+K35PQjUpYgcoNy5+Sw3CNS/NHn4JvOtTaUEYP7fK6c9LhMULOO3T7Cm6TMdiFjUKHkyG+s2Mu/LXJJoilw571zwuh6chkeitW8+Ht7k0aPV96kNEvTdoXwLhBifVEaChlAsLAzSUjUq+YYCiXVk0VIXCZQWKj8LoVNTmaqDksWwbcT64fw/FpVC0N18WHbKcFUEIW/O4spJMa30CQwf9FeqpoWoaF1oRClCSDPvX0AauCu0JcmRinz1/JmlXljnXWbSfm20/V+WyvktlI0wTD0cdpNuSasT9vS77YfJ8nutcWWZKSkCj4R4uHeCNpDTX5YXzapy7FxpM9ANCXLIvoGX7Yafba2Po+er7SSsUIY1AsnBBr8ZoDVw==" + ]; + }; + }; +} diff --git a/nix/modules/nixos/virtualisation/default.nix b/nix/modules/nixos/virtualisation/default.nix index 7817ed4..c915eb0 100644 --- a/nix/modules/nixos/virtualisation/default.nix +++ b/nix/modules/nixos/virtualisation/default.nix @@ -1,10 +1 @@ -# TODO: Why is this needed just for this directory? -# In the other directories this will create the modules twice. -# Perhaps because there's only a single sub directory here? -args@{ lib, ... }: -let - modules = lib.khscodes.dirsInPath ./.; -in -{ - imports = lib.lists.map (d: import d args) modules; -} +{ ... }: { } diff --git a/nix/modules/nixos/virtualisation/qemu-guest/default.nix b/nix/modules/nixos/virtualisation/qemu-guest/default.nix index a902f0e..4ab6ae4 100644 --- a/nix/modules/nixos/virtualisation/qemu-guest/default.nix +++ b/nix/modules/nixos/virtualisation/qemu-guest/default.nix @@ -6,11 +6,41 @@ }: let cfg = config.khscodes.virtualisation.qemu-guest; + rng = "-device virtio-rng-pci,rng=rng0 -object rng-random,id=rng0,filename=/dev/urandom"; + spice = [ + "-spice disable-ticketing=on,gl=on,unix=on,addr=/tmp/spice.sock" + "-device virtio-serial-pci" + "-chardev socket,id=agent0,path=vm.sock,server=on,wait=off" + "-device virtserialport,chardev=agent0,name=org.qemu.guest_agent.0" + "-chardev spicevmc,id=vdagent0,name=vdagent" + "-device virtserialport,chardev=vdagent0,name=com.redhat.spice.0" + "-chardev spiceport,id=webdav0,name=org.spice-space.webdav.0" + "-device virtserialport,chardev=webdav0,name=org.spice-space.webdav.0" + ]; in { options.khscodes.virtualisation.qemu-guest = { enable = lib.mkEnableOption "Configures machine with NixOS profile for qemu guest"; + enableWhenVmTarget = lib.mkEnableOption "Enables some enhancement settings when building as a vm"; }; - config = lib.mkIf cfg.enable (import "${modulesPath}/profiles/qemu-guest.nix" { }); + imports = [ "${modulesPath}/virtualisation/qemu-vm.nix" ]; + + config = lib.mkIf cfg.enableWhenVmTarget { + virtualisation = { + vmVariant = { + services.qemuGuest.enable = true; + services.spice-vdagentd.enable = true; + khscodes.virtualisation.qemu-guest.enable = true; + }; + memorySize = 1024 * 8; + qemu = { + options = [ + "-smp 8" + "-vga none -device virtio-gpu-gl,hostmem=2G,blob=true,venus=true" + rng + ] ++ spice; + }; + }; + }; } diff --git a/nix/modules/nixos/virtualisation/qemu-guest/profile.nix b/nix/modules/nixos/virtualisation/qemu-guest/profile.nix new file mode 100644 index 0000000..77560ee --- /dev/null +++ b/nix/modules/nixos/virtualisation/qemu-guest/profile.nix @@ -0,0 +1,12 @@ +{ + config, + lib, + modulesPath, + ... +}: +let + cfg = config.khscodes.virtualisation.qemu-guest; +in +{ + config = lib.mkIf cfg.enable (import "${modulesPath}/profiles/qemu-guest.nix" { }); +} diff --git a/nix/packages/start-vm/default.nix b/nix/packages/start-vm/default.nix new file mode 100644 index 0000000..7cd65c4 --- /dev/null +++ b/nix/packages/start-vm/default.nix @@ -0,0 +1,24 @@ +{ pkgs, inputs, ... }: +pkgs.writeShellApplication { + name = "start-vm"; + runtimeInputs = [ + pkgs.spice-gtk + pkgs.uutils-findutils + ]; + text = '' + host="''${1:-}" + clean="''${2:-no}" + if [[ "$clean" == "clean" ]]; then + find . -type f -name '*.qcow2' -delete + fi + run_vm="$(nix build --no-link --print-out-paths '${inputs.self}#nixosConfigurations."'"$host"'".config.system.build.vm' --show-trace)" + + # shellcheck disable=SC2211 + # shellcheck disable=SC2086 + $run_vm/bin/* & + pid=$! + trap 'kill $pid' EXIT + sleep 2 + spicy --title "$host" --uri=spice+unix:///tmp/spice.sock + ''; +} diff --git a/nix/profiles/home/khs-base.nix b/nix/profiles/home/khs-base.nix new file mode 100644 index 0000000..11421cd --- /dev/null +++ b/nix/profiles/home/khs-base.nix @@ -0,0 +1,4 @@ +{ + khscodes.khs.enable = true; + khscodes.khs.shell.oh-my-posh.enable = true; +} diff --git a/nix/profiles/home/khs-desktop.nix b/nix/profiles/home/khs-desktop.nix new file mode 100644 index 0000000..8dd0230 --- /dev/null +++ b/nix/profiles/home/khs-desktop.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: +{ + imports = [ ./khs-base.nix ]; + home.packages = [ + pkgs.bitwarden-cli + pkgs.nerd-fonts.inconsolata + pkgs.google-chrome + ]; + khscodes = { + desktop.enable = true; + }; +} diff --git a/nix/profiles/home/khs-linux-desktop.nix b/nix/profiles/home/khs-linux-desktop.nix new file mode 100644 index 0000000..3241e5b --- /dev/null +++ b/nix/profiles/home/khs-linux-desktop.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: +{ + imports = [ ./khs-desktop.nix ]; + home.packages = [ pkgs.spotify ]; +} diff --git a/nix/profiles/hetzner-server.nix b/nix/profiles/nixos/hetzner-server.nix similarity index 76% rename from nix/profiles/hetzner-server.nix rename to nix/profiles/nixos/hetzner-server.nix index da9068b..ae5cccc 100644 --- a/nix/profiles/hetzner-server.nix +++ b/nix/profiles/nixos/hetzner-server.nix @@ -1,5 +1,6 @@ { ... }: { + imports = [ ./nix-base.nix ]; config.khscodes = { hetzner.enable = true; services.openssh.enable = true; diff --git a/nix/profiles/nixos/khs-base.nix b/nix/profiles/nixos/khs-base.nix new file mode 100644 index 0000000..07d84db --- /dev/null +++ b/nix/profiles/nixos/khs-base.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: +{ + imports = [ ./nix-base.nix ]; + snowfallorg.users.khs.admin = true; + users.users.khs = { + # TODO: Figure out how to provision password changes to servers from VAULT + initialPassword = "changeme"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqY0FHnWFKfLG2yfgr4qka5sR9CK+EMAhzlHUkaQyWHTKD+G0/vC/fNPyL1VV3Dxc/ajxGuPzVE+mBMoyxazL3EtuCDOVvHJ5CR+MUSEckg/DDwcGHqy6rC8BvVVpTAVL04ByQdwFnpE1qNSBaQLkxaFVdtriGKkgMkc7+UNeYX/bv7yn+APqfP1a3xr6wdkSSdO8x4N2jsSygOIMx10hLyCV4Ueu7Kp8Ww4rGY8j5o7lKJhbgfItBfSOuQHdppHVF/GKYRhdnK6Y2fZVYbhq4KipUtclbZ6O/VYd8/sOO98+LMm7cOX+K35PQjUpYgcoNy5+Sw3CNS/NHn4JvOtTaUEYP7fK6c9LhMULOO3T7Cm6TMdiFjUKHkyG+s2Mu/LXJJoilw571zwuh6chkeitW8+Ht7k0aPV96kNEvTdoXwLhBifVEaChlAsLAzSUjUq+YYCiXVk0VIXCZQWKj8LoVNTmaqDksWwbcT64fw/FpVC0N18WHbKcFUEIW/O4spJMa30CQwf9FeqpoWoaF1oRClCSDPvX0AauCu0JcmRinz1/JmlXljnXWbSfm20/V+WyvktlI0wTD0cdpNuSasT9vS77YfJ8nutcWWZKSkCj4R4uHeCNpDTX5YXzapy7FxpM9ANCXLIvoGX7Yafba2Po+er7SSsUIY1AsnBBr8ZoDVw==" + ]; + }; + environment = { + systemPackages = [ pkgs.openbao ]; + variables = { + BAO_ADDR = "https://vault.kaareskovgaard.net"; + }; + }; +} diff --git a/nix/profiles/nixos/khs-desktop.nix b/nix/profiles/nixos/khs-desktop.nix new file mode 100644 index 0000000..8e653a0 --- /dev/null +++ b/nix/profiles/nixos/khs-desktop.nix @@ -0,0 +1,38 @@ +{ + lib, + pkgs, + inputs, + ... +}: +{ + imports = [ ./khs-base.nix ]; + khscodes.virtualisation.qemu-guest.enableWhenVmTarget = true; + + services.desktopManager.cosmic.enable = true; + services.displayManager.cosmic-greeter.enable = true; + + stylix = { + enable = true; + autoEnable = false; + image = "${inputs.self}/assets/khs-desktop-wallpaper.jpg"; + base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/solarized-dark.yaml"; + targets.console.enable = true; + fonts = { + monospace = { + package = pkgs.nerd-fonts.inconsolata; + name = "Inconsolata Nerd Font"; + }; + sizes = { + terminal = 14; + }; + }; + }; + console = { + enable = true; + font = "${pkgs.powerline-fonts}/share/consolefonts/ter-powerline-v24b.psf.gz"; + packages = [ + pkgs.terminus_font + pkgs.powerline-fonts + ]; + }; +} diff --git a/nix/profiles/khs-openstack-server.nix b/nix/profiles/nixos/khs-openstack-server.nix similarity index 76% rename from nix/profiles/khs-openstack-server.nix rename to nix/profiles/nixos/khs-openstack-server.nix index dafafd2..02e2333 100644 --- a/nix/profiles/khs-openstack-server.nix +++ b/nix/profiles/nixos/khs-openstack-server.nix @@ -1,5 +1,6 @@ { ... }: { + imports = [ ./nix-base.nix ]; config.khscodes = { openstack.enable = true; services.openssh.enable = true; diff --git a/nix/profiles/nixos/khs-server.nix b/nix/profiles/nixos/khs-server.nix new file mode 100644 index 0000000..25e8c3f --- /dev/null +++ b/nix/profiles/nixos/khs-server.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ ./nix-base.nix ]; + config.khscodes = { + services.openssh.enable = true; + }; +} diff --git a/nix/profiles/nix-base.nix b/nix/profiles/nixos/nix-base.nix similarity index 100% rename from nix/profiles/nix-base.nix rename to nix/profiles/nixos/nix-base.nix diff --git a/nix/systems/aarch64-linux/khs.codes/default.nix b/nix/systems/aarch64-linux/khs.codes/default.nix index 0d8a456..6b2fe88 100644 --- a/nix/systems/aarch64-linux/khs.codes/default.nix +++ b/nix/systems/aarch64-linux/khs.codes/default.nix @@ -10,6 +10,6 @@ server_type = "cax11"; secretsSource = "bitwarden"; }; - khscodes.fqdn = "khs.codes"; + khscodes.networking.fqdn = "khs.codes"; system.stateVersion = "25.05"; } diff --git a/nix/systems/x86_64-linux/desktop.kaareskovgaard.net/default.nix b/nix/systems/x86_64-linux/desktop.kaareskovgaard.net/default.nix new file mode 100644 index 0000000..5a5ac3b --- /dev/null +++ b/nix/systems/x86_64-linux/desktop.kaareskovgaard.net/default.nix @@ -0,0 +1,9 @@ +{ + inputs, + ... +}: +{ + imports = [ "${inputs.self}/nix/profiles/nixos/khs-desktop.nix" ]; + khscodes.networking.fqdn = "desktop.kaareskovgaard.net"; + system.stateVersion = "25.05"; +} diff --git a/nix/systems/x86_64-linux/test.kaareskovgaard.net/default.nix b/nix/systems/x86_64-linux/test.kaareskovgaard.net/default.nix index ddfcb62..5d50c30 100644 --- a/nix/systems/x86_64-linux/test.kaareskovgaard.net/default.nix +++ b/nix/systems/x86_64-linux/test.kaareskovgaard.net/default.nix @@ -11,11 +11,11 @@ }; snowfallorg.users.khs.admin = true; users.users.khs = { - initialPassword = "test"; + initialPassword = "changeMe"; openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqY0FHnWFKfLG2yfgr4qka5sR9CK+EMAhzlHUkaQyWHTKD+G0/vC/fNPyL1VV3Dxc/ajxGuPzVE+mBMoyxazL3EtuCDOVvHJ5CR+MUSEckg/DDwcGHqy6rC8BvVVpTAVL04ByQdwFnpE1qNSBaQLkxaFVdtriGKkgMkc7+UNeYX/bv7yn+APqfP1a3xr6wdkSSdO8x4N2jsSygOIMx10hLyCV4Ueu7Kp8Ww4rGY8j5o7lKJhbgfItBfSOuQHdppHVF/GKYRhdnK6Y2fZVYbhq4KipUtclbZ6O/VYd8/sOO98+LMm7cOX+K35PQjUpYgcoNy5+Sw3CNS/NHn4JvOtTaUEYP7fK6c9LhMULOO3T7Cm6TMdiFjUKHkyG+s2Mu/LXJJoilw571zwuh6chkeitW8+Ht7k0aPV96kNEvTdoXwLhBifVEaChlAsLAzSUjUq+YYCiXVk0VIXCZQWKj8LoVNTmaqDksWwbcT64fw/FpVC0N18WHbKcFUEIW/O4spJMa30CQwf9FeqpoWoaF1oRClCSDPvX0AauCu0JcmRinz1/JmlXljnXWbSfm20/V+WyvktlI0wTD0cdpNuSasT9vS77YfJ8nutcWWZKSkCj4R4uHeCNpDTX5YXzapy7FxpM9ANCXLIvoGX7Yafba2Po+er7SSsUIY1AsnBBr8ZoDVw==" ]; }; - khscodes.fqdn = "test.kaareskovgaard.net"; + khscodes.networking.fqdn = "test.kaareskovgaard.net"; system.stateVersion = "25.05"; }