diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-09-21 19:15:50 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-09-22 00:18:59 +0200 |
commit | 242c2b6bf1649887ac9bdc8ef83f853c9fb91cc9 (patch) | |
tree | 65cfc499bc1997a0c3a2591a83f84421027938de | |
parent | mkHost: Add extraModules argument (diff) | |
download | nixos-config-242c2b6bf1649887ac9bdc8ef83f853c9fb91cc9.tar.gz nixos-config-242c2b6bf1649887ac9bdc8ef83f853c9fb91cc9.tar.bz2 nixos-config-242c2b6bf1649887ac9bdc8ef83f853c9fb91cc9.zip |
Flake: Add systems as 'input' to the nix derivation
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | flake.nix | 13 | ||||
-rw-r--r-- | hosts/default.nix | 9 |
3 files changed, 21 insertions, 11 deletions
diff --git a/README.md b/README.md index 3d6b3bc..251c5ec 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ My Personal NixOS Flake. ## Installing ``` -nixos-install --flake . #HOST-HARDWARE +nixos-install --flake . #$HOST-$HARDWARE-ARCH ``` ## Updating @@ -14,23 +14,23 @@ nixos-install --flake . #HOST-HARDWARE ``` nix flake update -nixos-rebuild switch --flake . #HOST-HARDWARE +nixos-rebuild switch --flake . #$HOST-$HARDWARE-ARCH ``` # Non-Nixos ## Installing ``` -nix build .#homeManagerConfigurations.HOST-HARDWARE.activationPackage +nix build .#homeManagerConfigurations.$HOST-$HARDWARE-$ARCH.activationPackage ./result/activate ``` ## Updating ``` -home-manager switch --flake .#HOST-HARDWARE +home-manager switch --flake .#$HOST-$HARDWARE-$ARCH ``` # ISO ## Building ``` -nix build .#isoConfigurations.HOST-HARDWARE.config.system.build.isoImage +nix build .#isoConfigurations.$HOST-$HARDWARE-$ARCH.config.system.build.isoImage ``` diff --git a/flake.nix b/flake.nix index 97627c2..9d87f10 100644 --- a/flake.nix +++ b/flake.nix @@ -32,8 +32,8 @@ dotfiles = ./dotfiles; hosts = [ - { host = "phobos"; system = "x86_64-linux"; extraOverlays = [ ]; extraModules = [ ]; timezone = secrets.main_timezone; location = secrets.main_location; } - { host = "luna"; system = "x86_64-linux"; extraOverlays = [ ]; extraModules = [ ]; timezone = secrets.main_timezone; location = secrets.main_location; } + { host = "phobos"; extraOverlays = [ ]; extraModules = [ ]; timezone = secrets.main_timezone; location = secrets.main_location; } + { host = "luna"; extraOverlays = [ ]; extraModules = [ ]; timezone = secrets.main_timezone; location = secrets.main_location; } ]; hardwares = [ @@ -42,11 +42,18 @@ { hardware = "virtualbox"; } ]; + systems = [ + { system = "x86_64-linux"; } + { system = "x86_64-darwin"; } + { system = "aarch64-linux"; } + { system = "aarch64-darwin"; } + ]; + commonInherits = { inherit (nixpkgs) lib; inherit inputs nixpkgs home-manager; - inherit user secrets dotfiles hosts hardwares; + inherit user secrets dotfiles hosts hardwares systems; }; in { diff --git a/hosts/default.nix b/hosts/default.nix index 2624f14..d1639b8 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,4 +1,4 @@ -{ lib, inputs, secrets, dotfiles, hosts, hardwares, isNixOS, isIso, isHardware, user, nixpkgs, home-manager, ... }: +{ lib, inputs, secrets, dotfiles, hosts, hardwares, systems, isNixOS, isIso, isHardware, user, nixpkgs, home-manager, ... }: let mkHost = { host, hardware, system, timezone, location, extraOverlays, extraModules }: isNixOS: isIso: isHardware: let @@ -7,6 +7,7 @@ let config = { allowUnfree = true; allowBroken = true; + allowUnsupportedSystem = true; }; overlays = [ inputs.nur.overlay @@ -53,11 +54,13 @@ let ]; }; - permutatedHosts = lib.concatMap (hardware: map (host: host // hardware) hosts) hardwares; + hardwarePermutatedHosts = lib.concatMap (hardware: map (host: host // hardware) hosts) hardwares; + systemsPermutatedHosts = lib.concatMap (system: map (host: host // system) hardwarePermutatedHosts) systems; + permutatedHosts = systemsPermutatedHosts; in /* We have a list of sets. Map each element of the list applying the mkHost function to its elements and returning a set in the listToAttrs format builtins.listToAttrs on the result */ -builtins.listToAttrs (map (mInput@{ host, hardware, ... }: { name = host + "-" + hardware; value = mkHost mInput isNixOS isIso isHardware; }) permutatedHosts) +builtins.listToAttrs (map (mInput@{ host, hardware, system, ... }: { name = host + "-" + hardware + "-" + system; value = mkHost mInput isNixOS isIso isHardware; }) permutatedHosts) |