refactor!: multi-host setup

This commit is contained in:
2025-01-21 08:18:09 +00:00
parent b03daef66c
commit c03f3cb182
7 changed files with 46 additions and 37 deletions

View File

@@ -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?
}

View File

@@ -24,13 +24,10 @@
meta = { hostname = host.name; }; meta = { hostname = host.name; };
}; };
system = "x86_64-linux"; system = "x86_64-linux";
modules = modules = [
[ ./configuration.nix home-manager.nixosModules.home-manager ] ./hosts/${host.name}/configuration.nix
++ (if host.isWSL then [ home-manager.nixosModules.home-manager
./wsl.nix ] ++ (if host.isWSL then [ nixos-wsl.nixosModules.default ] else [ ]);
nixos-wsl.nixosModules.default
] else
[ ]);
}; };
}) hosts); }) hosts);
}; };

View File

@@ -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";
}

View File

@@ -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 ];
}

1
nix/modules/default.nix Normal file
View File

@@ -0,0 +1 @@
{ pkgs, lib, config, ... }: { imports = [ ./commonPackages.nix ./hm.nix ]; }

11
nix/modules/hm.nix Normal file
View File

@@ -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;
};
}

View File

@@ -1,4 +0,0 @@
{
wsl.enable = true;
wsl.defaultUser = "luca";
}