From c03f3cb18266807928e01258fdcd3ca6b824f7e7 Mon Sep 17 00:00:00 2001 From: rocketcamel Date: Tue, 21 Jan 2025 08:18:09 +0000 Subject: [PATCH] refactor!: multi-host setup --- nix/configuration.nix | 26 ------------------------ nix/flake.nix | 11 ++++------ nix/hosts/wsl-kumatani/configuration.nix | 20 ++++++++++++++++++ nix/modules/commonPackages.nix | 10 +++++++++ nix/modules/default.nix | 1 + nix/modules/hm.nix | 11 ++++++++++ nix/wsl.nix | 4 ---- 7 files changed, 46 insertions(+), 37 deletions(-) delete mode 100644 nix/configuration.nix create mode 100644 nix/hosts/wsl-kumatani/configuration.nix create mode 100644 nix/modules/commonPackages.nix create mode 100644 nix/modules/default.nix create mode 100644 nix/modules/hm.nix delete mode 100644 nix/wsl.nix diff --git a/nix/configuration.nix b/nix/configuration.nix deleted file mode 100644 index e35527d..0000000 --- a/nix/configuration.nix +++ /dev/null @@ -1,26 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page, on -# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). - -{ config, lib, pkgs, meta, ... }: - -{ - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - environment.systemPackages = with pkgs; [ wget busybox stow ]; - programs.nix-ld.enable = true; - networking.hostName = meta.hostname; - - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.luca = import ./users/luca/home.nix; - users.users.luca.shell = pkgs.zsh; - programs.zsh.enable = true; - - # 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 = "24.05"; # Did you read the comment? -} diff --git a/nix/flake.nix b/nix/flake.nix index 2984e35..edb526c 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -24,13 +24,10 @@ meta = { hostname = host.name; }; }; system = "x86_64-linux"; - modules = - [ ./configuration.nix home-manager.nixosModules.home-manager ] - ++ (if host.isWSL then [ - ./wsl.nix - nixos-wsl.nixosModules.default - ] else - [ ]); + modules = [ + ./hosts/${host.name}/configuration.nix + home-manager.nixosModules.home-manager + ] ++ (if host.isWSL then [ nixos-wsl.nixosModules.default ] else [ ]); }; }) hosts); }; diff --git a/nix/hosts/wsl-kumatani/configuration.nix b/nix/hosts/wsl-kumatani/configuration.nix new file mode 100644 index 0000000..947c46f --- /dev/null +++ b/nix/hosts/wsl-kumatani/configuration.nix @@ -0,0 +1,20 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, meta, ... }: + +{ + imports = [ ../../modules/default.nix ]; + + wsl.enable = true; + wsl.defaultUser = "luca"; + networking.hostName = meta.hostname; + programs.nix-ld.enable = true; + hm.enable = true; + + environment.systemPackages = with pkgs; + config.commonPackages ++ [ asciiquarium ]; + + system.stateVersion = "24.05"; +} diff --git a/nix/modules/commonPackages.nix b/nix/modules/commonPackages.nix new file mode 100644 index 0000000..b6c8922 --- /dev/null +++ b/nix/modules/commonPackages.nix @@ -0,0 +1,10 @@ +{ pkgs, lib, ... }: { + options = { + commonPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + description = "Common packages"; + }; + }; + config.commonPackages = with pkgs; [ wget busybox curl ]; +} diff --git a/nix/modules/default.nix b/nix/modules/default.nix new file mode 100644 index 0000000..2d16832 --- /dev/null +++ b/nix/modules/default.nix @@ -0,0 +1 @@ +{ pkgs, lib, config, ... }: { imports = [ ./commonPackages.nix ./hm.nix ]; } diff --git a/nix/modules/hm.nix b/nix/modules/hm.nix new file mode 100644 index 0000000..0f47d39 --- /dev/null +++ b/nix/modules/hm.nix @@ -0,0 +1,11 @@ +{ lib, config, pkgs, ... }: { + options = { hm.enable = lib.mkEnableOption "enable home-manager"; }; + + config = lib.mkIf config.hm.enable { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.luca = import ../users/luca/home.nix; + users.users.luca.shell = pkgs.zsh; + programs.zsh.enable = true; + }; +} diff --git a/nix/wsl.nix b/nix/wsl.nix deleted file mode 100644 index 8439e3a..0000000 --- a/nix/wsl.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - wsl.enable = true; - wsl.defaultUser = "luca"; -}