From f4ac9f3186600dc2914e4924b713a1dee4b75ca2 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 14 Jun 2023 17:28:00 +0200 Subject: [PATCH] Simplify flake and expose host pkgs The configuration of the machines is now moved to m/ --- common/overlays.nix | 9 -- flake.nix | 105 +++--------------- {common => m/common}/boot.nix | 0 {common => m/common}/fs.nix | 0 {common => m/common}/hw.nix | 0 {common => m/common}/main.nix | 19 +++- {common => m/common}/net.nix | 4 +- {common => m/common}/slurm.nix | 3 +- {common => m/common}/ssh.nix | 0 {common => m/common}/users.nix | 0 {hut => m/hut}/configuration.nix | 3 +- {hut => m/hut}/gitlab-runner.nix | 0 {hut => m/hut}/monitoring.nix | 0 {hut => m/hut}/nfs.nix | 0 {hut => m/hut}/secrets.nix | 0 {hut => m/hut}/secrets/nosv-token.age | Bin {hut => m/hut}/secrets/ovni-token.age | 0 {hut => m/hut}/slurm-daemon.nix | 0 {xeon01 => m/owl1}/configuration.nix | 0 {xeon02 => m/owl2}/configuration.nix | 0 {xeon08 => m/xeon08}/configuration.nix | 0 {xeon08 => m/xeon08}/cpufreq.nix | 0 {xeon08 => m/xeon08}/fs.nix | 0 {xeon08 => m/xeon08}/kernel/configs/defconfig | 0 {xeon08 => m/xeon08}/kernel/configs/lockdep | 0 {xeon08 => m/xeon08}/kernel/kernel.nix | 0 {xeon08 => m/xeon08}/kernel/lttng.nix | 0 {xeon08 => m/xeon08}/kernel/perf.nix | 0 {xeon08 => m/xeon08}/slurm.nix | 0 {xeon08 => m/xeon08}/users.nix | 0 overlays-compat/overlays.nix | 8 -- 31 files changed, 39 insertions(+), 112 deletions(-) delete mode 100644 common/overlays.nix rename {common => m/common}/boot.nix (100%) rename {common => m/common}/fs.nix (100%) rename {common => m/common}/hw.nix (100%) rename {common => m/common}/main.nix (80%) rename {common => m/common}/net.nix (96%) rename {common => m/common}/slurm.nix (61%) rename {common => m/common}/ssh.nix (100%) rename {common => m/common}/users.nix (100%) rename {hut => m/hut}/configuration.nix (89%) rename {hut => m/hut}/gitlab-runner.nix (100%) rename {hut => m/hut}/monitoring.nix (100%) rename {hut => m/hut}/nfs.nix (100%) rename {hut => m/hut}/secrets.nix (100%) rename {hut => m/hut}/secrets/nosv-token.age (100%) rename {hut => m/hut}/secrets/ovni-token.age (100%) rename {hut => m/hut}/slurm-daemon.nix (100%) rename {xeon01 => m/owl1}/configuration.nix (100%) rename {xeon02 => m/owl2}/configuration.nix (100%) rename {xeon08 => m/xeon08}/configuration.nix (100%) rename {xeon08 => m/xeon08}/cpufreq.nix (100%) rename {xeon08 => m/xeon08}/fs.nix (100%) rename {xeon08 => m/xeon08}/kernel/configs/defconfig (100%) rename {xeon08 => m/xeon08}/kernel/configs/lockdep (100%) rename {xeon08 => m/xeon08}/kernel/kernel.nix (100%) rename {xeon08 => m/xeon08}/kernel/lttng.nix (100%) rename {xeon08 => m/xeon08}/kernel/perf.nix (100%) rename {xeon08 => m/xeon08}/slurm.nix (100%) rename {xeon08 => m/xeon08}/users.nix (100%) delete mode 100644 overlays-compat/overlays.nix diff --git a/common/overlays.nix b/common/overlays.nix deleted file mode 100644 index fdf0706..0000000 --- a/common/overlays.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ options, ... }: - -{ - nix.nixPath = - # Prepend default nixPath values. - options.nix.nixPath.default ++ - # Append our nixpkgs-overlays. - [ "nixpkgs-overlays=${../overlays-compat}" ]; -} diff --git a/flake.nix b/flake.nix index d3fc4ae..54642d0 100644 --- a/flake.nix +++ b/flake.nix @@ -6,97 +6,22 @@ bscpkgs.url = "git+https://pm.bsc.es/gitlab/rarias/bscpkgs.git"; }; - outputs = { self, nixpkgs, agenix, bscpkgs, ... }: { + outputs = { self, nixpkgs, agenix, bscpkgs, ... }: +let + mkConf = name: nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit nixpkgs bscpkgs agenix; theFlake = self; }; + modules = [ "${self.outPath}/m/${name}/configuration.nix" ]; + }; +in + { nixosConfigurations = { - xeon01 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ( {options, ...}: { - # Sel the nixos-config path to the one of the current flake - nixpkgs.overlays = [ bscpkgs.bscOverlay ]; - nix.nixPath = [ - "nixpkgs=${nixpkgs}" - "bscpkgs=${bscpkgs}" - "nixos-config=${self.outPath}/xeon01/configuration.nix" - "nixpkgs-overlays=${self.outPath}/overlays-compat" - ]; - nix.registry.nixpkgs.flake = nixpkgs; - nix.registry.bscpkgs.flake = bscpkgs; - system.configurationRevision = - if self ? rev - then self.rev - else throw ("Refusing to build from a dirty Git tree!"); - }) - ./xeon01/configuration.nix - ]; - }; - xeon02 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ( {options, ...}: { - # Sel the nixos-config path to the one of the current flake - nixpkgs.overlays = [ bscpkgs.bscOverlay ]; - nix.nixPath = [ - "nixpkgs=${nixpkgs}" - "bscpkgs=${bscpkgs}" - "nixos-config=${self.outPath}/xeon02/configuration.nix" - "nixpkgs-overlays=${self.outPath}/overlays-compat" - ]; - nix.registry.nixpkgs.flake = nixpkgs; - nix.registry.bscpkgs.flake = bscpkgs; - system.configurationRevision = - if self ? rev - then self.rev - else throw ("Refusing to build from a dirty Git tree!"); - }) - ./xeon02/configuration.nix - ]; - }; - hut = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ( {options, ...}: { - # Sel the nixos-config path to the one of the current flake - nixpkgs.overlays = [ bscpkgs.bscOverlay ]; - nix.nixPath = [ - "nixpkgs=${nixpkgs}" - "bscpkgs=${bscpkgs}" - "nixos-config=${self.outPath}/hut/configuration.nix" - "nixpkgs-overlays=${self.outPath}/overlays-compat" - ]; - nix.registry.nixpkgs.flake = nixpkgs; - nix.registry.bscpkgs.flake = bscpkgs; - system.configurationRevision = - if self ? rev - then self.rev - else throw ("Refusing to build from a dirty Git tree!"); - }) - agenix.nixosModules.default - ./hut/configuration.nix - ]; - }; - xeon08 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ( {options, ...}: { - # Sel the nixos-config path to the one of the current flake - nixpkgs.overlays = [ bscpkgs.bscOverlay ]; - nix.nixPath = [ - "nixpkgs=${nixpkgs}" - "bscpkgs=${bscpkgs}" - "nixos-config=${self.outPath}/xeon08/configuration.nix" - "nixpkgs-overlays=${self.outPath}/overlays-compat" - ]; - nix.registry.nixpkgs.flake = nixpkgs; - nix.registry.bscpkgs.flake = bscpkgs; - system.configurationRevision = - if self ? rev - then self.rev - else throw ("Refusing to build from a dirty Git tree!"); - }) - ./xeon08/configuration.nix - ]; - }; + hut = mkConf "hut"; + owl1 = mkConf "owl1"; + owl2 = mkConf "owl2"; + xeon08 = mkConf "xeon08"; }; + + packages.x86_64-linux.hut = self.nixosConfigurations.hut.pkgs; }; } diff --git a/common/boot.nix b/m/common/boot.nix similarity index 100% rename from common/boot.nix rename to m/common/boot.nix diff --git a/common/fs.nix b/m/common/fs.nix similarity index 100% rename from common/fs.nix rename to m/common/fs.nix diff --git a/common/hw.nix b/m/common/hw.nix similarity index 100% rename from common/hw.nix rename to m/common/hw.nix diff --git a/common/main.nix b/m/common/main.nix similarity index 80% rename from common/main.nix rename to m/common/main.nix index 59d5286..ba50376 100644 --- a/common/main.nix +++ b/m/common/main.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, nixpkgs, bscpkgs, agenix, theFlake, ... }: { imports = [ @@ -11,6 +11,23 @@ ./users.nix ]; + nixpkgs.overlays = [ bscpkgs.bscOverlay ]; + + nix.nixPath = [ + "nixpkgs=${nixpkgs}" + "bscpkgs=${bscpkgs}" + "jungle=${theFlake.outPath}" + ]; + + nix.registry.nixpkgs.flake = nixpkgs; + nix.registry.bscpkgs.flake = bscpkgs; + nix.registry.jungle.flake = theFlake; + + system.configurationRevision = + if theFlake ? rev + then theFlake.rev + else throw ("Refusing to build from a dirty Git tree!"); + environment.systemPackages = with pkgs; [ vim wget git htop tmux pciutils tcpdump ripgrep nix-index nixos-option nix-diff ipmitool freeipmi ethtool lm_sensors ix cmake gnumake file tree diff --git a/common/net.nix b/m/common/net.nix similarity index 96% rename from common/net.nix rename to m/common/net.nix index 51f80f4..504246c 100644 --- a/common/net.nix +++ b/m/common/net.nix @@ -43,12 +43,12 @@ 10.0.40.143 oss02-ipmi0 # Node Entry for node: xeon01 (ID=15) - 10.0.40.1 xeon01 xeon01-eth0 + 10.0.40.1 xeon01 xeon01-eth0 owl1 10.0.42.1 xeon01-ib0 10.0.40.101 xeon01-ipmi0 # Node Entry for node: xeon02 (ID=16) - 10.0.40.2 xeon02 xeon02-eth0 + 10.0.40.2 xeon02 xeon02-eth0 owl2 10.0.42.2 xeon02-ib0 10.0.40.102 xeon02-ipmi0 diff --git a/common/slurm.nix b/m/common/slurm.nix similarity index 61% rename from common/slurm.nix rename to m/common/slurm.nix index 2da5a02..c208b88 100644 --- a/common/slurm.nix +++ b/m/common/slurm.nix @@ -6,7 +6,8 @@ controlMachine = "hut"; clusterName = "owl"; nodeName = [ - "xeon[01-02,07] Sockets=2 CoresPerSocket=14 ThreadsPerCore=2 Feature=xeon" + "owl[1,2] Sockets=2 CoresPerSocket=14 ThreadsPerCore=2 Feature=owl" + "hut Sockets=2 CoresPerSocket=14 ThreadsPerCore=2" ]; extraConfig = '' MpiDefault=pmix diff --git a/common/ssh.nix b/m/common/ssh.nix similarity index 100% rename from common/ssh.nix rename to m/common/ssh.nix diff --git a/common/users.nix b/m/common/users.nix similarity index 100% rename from common/users.nix rename to m/common/users.nix diff --git a/hut/configuration.nix b/m/hut/configuration.nix similarity index 89% rename from hut/configuration.nix rename to m/hut/configuration.nix index 423b18d..82d4c34 100644 --- a/hut/configuration.nix +++ b/m/hut/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, agenix, ... }: { imports = [ @@ -8,6 +8,7 @@ ./monitoring.nix ./nfs.nix ./slurm-daemon.nix + agenix.nixosModules.default ]; # Select the this using the ID to avoid mismatches diff --git a/hut/gitlab-runner.nix b/m/hut/gitlab-runner.nix similarity index 100% rename from hut/gitlab-runner.nix rename to m/hut/gitlab-runner.nix diff --git a/hut/monitoring.nix b/m/hut/monitoring.nix similarity index 100% rename from hut/monitoring.nix rename to m/hut/monitoring.nix diff --git a/hut/nfs.nix b/m/hut/nfs.nix similarity index 100% rename from hut/nfs.nix rename to m/hut/nfs.nix diff --git a/hut/secrets.nix b/m/hut/secrets.nix similarity index 100% rename from hut/secrets.nix rename to m/hut/secrets.nix diff --git a/hut/secrets/nosv-token.age b/m/hut/secrets/nosv-token.age similarity index 100% rename from hut/secrets/nosv-token.age rename to m/hut/secrets/nosv-token.age diff --git a/hut/secrets/ovni-token.age b/m/hut/secrets/ovni-token.age similarity index 100% rename from hut/secrets/ovni-token.age rename to m/hut/secrets/ovni-token.age diff --git a/hut/slurm-daemon.nix b/m/hut/slurm-daemon.nix similarity index 100% rename from hut/slurm-daemon.nix rename to m/hut/slurm-daemon.nix diff --git a/xeon01/configuration.nix b/m/owl1/configuration.nix similarity index 100% rename from xeon01/configuration.nix rename to m/owl1/configuration.nix diff --git a/xeon02/configuration.nix b/m/owl2/configuration.nix similarity index 100% rename from xeon02/configuration.nix rename to m/owl2/configuration.nix diff --git a/xeon08/configuration.nix b/m/xeon08/configuration.nix similarity index 100% rename from xeon08/configuration.nix rename to m/xeon08/configuration.nix diff --git a/xeon08/cpufreq.nix b/m/xeon08/cpufreq.nix similarity index 100% rename from xeon08/cpufreq.nix rename to m/xeon08/cpufreq.nix diff --git a/xeon08/fs.nix b/m/xeon08/fs.nix similarity index 100% rename from xeon08/fs.nix rename to m/xeon08/fs.nix diff --git a/xeon08/kernel/configs/defconfig b/m/xeon08/kernel/configs/defconfig similarity index 100% rename from xeon08/kernel/configs/defconfig rename to m/xeon08/kernel/configs/defconfig diff --git a/xeon08/kernel/configs/lockdep b/m/xeon08/kernel/configs/lockdep similarity index 100% rename from xeon08/kernel/configs/lockdep rename to m/xeon08/kernel/configs/lockdep diff --git a/xeon08/kernel/kernel.nix b/m/xeon08/kernel/kernel.nix similarity index 100% rename from xeon08/kernel/kernel.nix rename to m/xeon08/kernel/kernel.nix diff --git a/xeon08/kernel/lttng.nix b/m/xeon08/kernel/lttng.nix similarity index 100% rename from xeon08/kernel/lttng.nix rename to m/xeon08/kernel/lttng.nix diff --git a/xeon08/kernel/perf.nix b/m/xeon08/kernel/perf.nix similarity index 100% rename from xeon08/kernel/perf.nix rename to m/xeon08/kernel/perf.nix diff --git a/xeon08/slurm.nix b/m/xeon08/slurm.nix similarity index 100% rename from xeon08/slurm.nix rename to m/xeon08/slurm.nix diff --git a/xeon08/users.nix b/m/xeon08/users.nix similarity index 100% rename from xeon08/users.nix rename to m/xeon08/users.nix diff --git a/overlays-compat/overlays.nix b/overlays-compat/overlays.nix deleted file mode 100644 index 8a606c5..0000000 --- a/overlays-compat/overlays.nix +++ /dev/null @@ -1,8 +0,0 @@ -self: super: -with super.lib; -let - # Load the system config and get the `nixpkgs.overlays` option - overlays = (import { }).config.nixpkgs.overlays; -in - # Apply all overlays to the input of the current "main" overlay - foldl' (flip extends) (_: super) overlays self