From 18121a0f9f16078047f0626468212684cdfa43f3 Mon Sep 17 00:00:00 2001 From: uku Date: Tue, 14 Nov 2023 18:29:14 +0100 Subject: [PATCH] move systems into a separate directory --- flake.nix | 40 ++----------- systems/common.nix | 59 +++++++++++++++++++ systems/default.nix | 44 ++++++++++++++ common.nix => systems/desktop.nix | 56 +----------------- {fuji => systems/fuji}/default.nix | 0 .../fuji}/hardware-configuration.nix | 0 {fuji => systems/fuji}/nvidia.nix | 0 .../kilimandjaro}/default.nix | 0 .../kilimandjaro}/hardware-configuration.nix | 0 9 files changed, 111 insertions(+), 88 deletions(-) create mode 100644 systems/common.nix create mode 100644 systems/default.nix rename common.nix => systems/desktop.nix (72%) rename {fuji => systems/fuji}/default.nix (100%) rename {fuji => systems/fuji}/hardware-configuration.nix (100%) rename {fuji => systems/fuji}/nvidia.nix (100%) rename {kilimandjaro => systems/kilimandjaro}/default.nix (100%) rename {kilimandjaro => systems/kilimandjaro}/hardware-configuration.nix (100%) diff --git a/flake.nix b/flake.nix index 9fa65df..98279e6 100644 --- a/flake.nix +++ b/flake.nix @@ -31,43 +31,13 @@ }; }; - outputs = { - flake-parts, - nixpkgs, - lanzaboote, - home-manager, - ... - } @ inputs: + outputs = {flake-parts, ...} @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux"]; - imports = [./dev.nix]; - - flake = let - mkSystem = modules: name: - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = - [ - ./${name} - ./${name}/hardware-configuration.nix - - {networking.hostName = name;} - ] - ++ modules; - specialArgs = inputs; - }; - - mkDesktop = mkSystem [ - ./common.nix - lanzaboote.nixosModules.lanzaboote - home-manager.nixosModules.home-manager - ]; - in { - nixosConfigurations = { - fuji = mkDesktop "fuji"; - kilimandjaro = mkDesktop "kilimandjaro"; - }; - }; + imports = [ + ./dev.nix + ./systems + ]; }; } diff --git a/systems/common.nix b/systems/common.nix new file mode 100644 index 0000000..f0aaad2 --- /dev/null +++ b/systems/common.nix @@ -0,0 +1,59 @@ +{ + pkgs, + nixpkgs, + ... +}: { + environment.systemPackages = with pkgs; [ + neovim + git + curl + nix-your-shell + ]; + + programs = { + fish = { + enable = true; + interactiveShellInit = '' + nix-your-shell fish | source + ''; + }; + + direnv.enable = true; + + command-not-found.enable = false; + nix-index = { + enable = true; + enableFishIntegration = true; + }; + }; + + nixpkgs.config.allowUnfree = true; + + nix = { + gc = { + automatic = true; + dates = "3d"; + options = "-d"; + }; + + settings = { + auto-optimise-store = true; + experimental-features = ["nix-command" "flakes"]; + }; + }; + + nix.registry = let + nixpkgsRegistry.flake = nixpkgs; + in { + nixpkgs = nixpkgsRegistry; + n = nixpkgsRegistry; + }; + + # 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 = "23.11"; # Did you read the comment? +} diff --git a/systems/default.nix b/systems/default.nix new file mode 100644 index 0000000..ef65cb0 --- /dev/null +++ b/systems/default.nix @@ -0,0 +1,44 @@ +{ + lib, + inputs, + ... +}: let + # shamelessly borrowed from https://github.com/getchoo/flake/blob/94dc521310b34b80158d1a0ab65d4daa3a44d81e/systems/default.nix + toSystem = builder: name: args: + (args.builder or builder) ( + (builtins.removeAttrs args ["builder"]) + // { + modules = + args.modules + ++ [ + ./common.nix + + ./${name} + ./${name}/hardware-configuration.nix + + {networking.hostName = name;} + ]; + specialArgs = inputs; + } + ); + + mapNixOS = lib.mapAttrs (toSystem inputs.nixpkgs.lib.nixosSystem); + + desktop = with inputs; [ + ./desktop.nix + lanzaboote.nixosModules.lanzaboote + home-manager.nixosModules.home-manager + ]; +in { + flake.nixosConfigurations = mapNixOS { + fuji = { + system = "x86_64-linux"; + modules = desktop; + }; + + kilimandjaro = { + system = "x86_64-linux"; + modules = desktop; + }; + }; +} diff --git a/common.nix b/systems/desktop.nix similarity index 72% rename from common.nix rename to systems/desktop.nix index 99b9130..20b70ff 100644 --- a/common.nix +++ b/systems/desktop.nix @@ -1,14 +1,13 @@ { lib, pkgs, - nixpkgs, getchvim, ... }: let username = "leo"; in { imports = [ - ./programs + ../programs (lib.mkAliasOptionModule ["hm"] ["home-manager" "users" username]) ]; @@ -132,7 +131,6 @@ in { osu-lazer-bin gnome.file-roller getchvim.packages.${system}.default - nix-your-shell ]; services = { @@ -145,27 +143,12 @@ in { }; programs = { - fish = { - enable = true; - interactiveShellInit = '' - nix-your-shell fish | source - ''; - }; - gnupg.agent = { enable = true; enableSSHSupport = true; pinentryFlavor = "gnome3"; }; - direnv.enable = true; - - command-not-found.enable = false; - nix-index = { - enable = true; - enableFishIntegration = true; - }; - seahorse.enable = true; steam.enable = true; @@ -191,40 +174,7 @@ in { (nerdfonts.override {fonts = ["Iosevka" "JetBrainsMono"];}) ]; - environment.systemPackages = with pkgs; [ - neovim - git - sbctl - ]; + environment.systemPackages = with pkgs; [sbctl]; - nixpkgs.config.allowUnfree = true; - - nix = { - gc = { - automatic = true; - dates = "3d"; - options = "-d"; - }; - - settings = { - auto-optimise-store = true; - experimental-features = ["nix-command" "flakes"]; - }; - }; - - nix.registry = let - nixpkgsRegistry.flake = nixpkgs; - in { - nixpkgs = nixpkgsRegistry; - n = nixpkgsRegistry; - }; - - # 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 = "23.05"; # Did you read the comment? - hm.home.stateVersion = "23.05"; + hm.home.stateVersion = "23.11"; } diff --git a/fuji/default.nix b/systems/fuji/default.nix similarity index 100% rename from fuji/default.nix rename to systems/fuji/default.nix diff --git a/fuji/hardware-configuration.nix b/systems/fuji/hardware-configuration.nix similarity index 100% rename from fuji/hardware-configuration.nix rename to systems/fuji/hardware-configuration.nix diff --git a/fuji/nvidia.nix b/systems/fuji/nvidia.nix similarity index 100% rename from fuji/nvidia.nix rename to systems/fuji/nvidia.nix diff --git a/kilimandjaro/default.nix b/systems/kilimandjaro/default.nix similarity index 100% rename from kilimandjaro/default.nix rename to systems/kilimandjaro/default.nix diff --git a/kilimandjaro/hardware-configuration.nix b/systems/kilimandjaro/hardware-configuration.nix similarity index 100% rename from kilimandjaro/hardware-configuration.nix rename to systems/kilimandjaro/hardware-configuration.nix