Compare commits

..

No commits in common. "5341235bc3435efa4cf3015954e06ca278570c1f" and "2352a1a9177fbb7d3fed042cc74f80e079196020" have entirely different histories.

22 changed files with 1066 additions and 1208 deletions

View file

@ -1,26 +1,26 @@
{
self,
deploy-rs,
...
}: let
{ self, deploy-rs, ... }:
let
deployArch = "x86_64-linux";
mkDeployNodes = nodeDef:
builtins.mapAttrs
(name: machine: nodeDef name machine)
self.machines.${deployArch};
in {
(name: machine: nodeDef name machine)
self.machines.${deployArch};
in
{
deploy = {
sshUser = "root";
user = "root";
nodes = mkDeployNodes (name: machine: let
nixosConfiguration = self.nixosConfigurations.${name};
in {
hostname = nixosConfiguration.config.networking.fqdn;
profiles.system = {
remoteBuild = machine.arch != deployArch;
path = deploy-rs.lib.${machine.arch}.activate.nixos nixosConfiguration;
};
});
nodes = mkDeployNodes (name: machine:
let
nixosConfiguration = self.nixosConfigurations.${name};
in
{
hostname = nixosConfiguration.config.networking.fqdn;
profiles.system = {
remoteBuild = machine.arch != deployArch;
path = deploy-rs.lib.${machine.arch}.activate.nixos nixosConfiguration;
};
});
};
}

116
flake.lock generated
View file

@ -109,22 +109,6 @@
"type": "github"
}
},
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@ -179,27 +163,6 @@
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"kubenix": {
"inputs": {
"flake-compat": "flake-compat_2",
@ -299,22 +262,6 @@
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1729357638,
"narHash": "sha256-66RHecx+zohbZwJVEPF7uuwHeqf8rykZTMCTqIrOew4=",
@ -362,45 +309,6 @@
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1726871744,
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_4",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs-unstable"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1729104314,
"narHash": "sha256-pZRZsq5oCdJt3upZIU4aslS9XwFJ+/nVtALHIciX/BI=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"deploy-rs": "deploy-rs",
@ -413,9 +321,7 @@
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2",
"nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit-hooks": "pre-commit-hooks",
"sops-nix": "sops-nix",
"treefmt-nix": "treefmt-nix"
"sops-nix": "sops-nix"
}
},
"sops-nix": {
@ -423,7 +329,7 @@
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1729775275,
@ -504,24 +410,6 @@
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1730025913,
"narHash": "sha256-Y9NtFmP8ciLyRsopcCx1tyoaaStKeq+EndwtGCgww7I=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "bae131e525cc8718da22fbeb8d8c7c43c4ea502a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"

View file

@ -17,12 +17,6 @@
deploy-rs.url = "github:serokell/deploy-rs";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
disko = {
url = "github:nix-community/disko";
@ -55,11 +49,8 @@
};
};
outputs = inputs @ {
nixpkgs,
flake-utils,
...
}:
outputs =
inputs@{ nixpkgs, flake-utils, ... }:
flake-utils.lib.meld inputs [
./scripts
./deploy.nix
@ -67,6 +58,7 @@
./shell.nix
./utils
./machines
./formatter.nix
];
] // (flake-utils.lib.eachDefaultSystem (system: {
formatter = nixpkgs.legacyPackages.${system}.nixfmt;
}));
}

View file

@ -1,14 +0,0 @@
{
nixpkgs,
treefmt-nix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in {
formatter = treefmtEval.config.build.wrapper;
}
)

View file

@ -1,13 +1,9 @@
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
{ nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
machineOpts = {config, ...}: {
machineOpts = { config, ... }: {
options = {
arch = lib.mkOption {
default = null;
@ -23,7 +19,7 @@ flake-utils.lib.eachDefaultSystem (system: let
};
nixosModule = lib.mkOption {
default = {...}: {};
default = { ... }: { };
type = lib.types.anything;
description = ''
Customized configuration for this machine in the form of a NixOS module.
@ -47,19 +43,17 @@ flake-utils.lib.eachDefaultSystem (system: let
};
};
};
in {
machines =
(lib.modules.evalModules {
modules = [
allOpts
./warwick.nix
./atlas.nix
./jefke.nix
./lewis.nix
# ./talos.nix
# ./pikvm.nix
];
})
.config
.machines;
in
{
machines = (lib.modules.evalModules {
modules = [
allOpts
./warwick.nix
./atlas.nix
./jefke.nix
./lewis.nix
# ./talos.nix
# ./pikvm.nix
];
}).config.machines;
})

View file

@ -3,12 +3,7 @@
arch = "aarch64-linux";
isRaspberryPi = true;
nixosModule = {
config,
inputs,
lib,
...
}: {
nixosModule = { config, inputs, lib, ... }: {
# imports = [ "${inputs.nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" ];
lab = {
storage.profile = "pi";
@ -22,7 +17,7 @@
v4l-utils
];
boot.extraModulePackages = with config.boot.kernelPackages; [v4l2loopback];
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
};
};
}

View file

@ -2,7 +2,7 @@
machines.talos = {
arch = "x86_64-linux";
nixosModule = {lib, ...}: {
nixosModule = { lib, ... }: {
lab.storage.profile = "normal";
# boot.loader.systemd-boot.enable = lib.mkForce false;

View file

@ -1,16 +1,12 @@
{
pkgs,
lib,
config,
...
}: let
{ pkgs, lib, config, ... }:
let
cfg = config.lab.backups;
borgmaticConfig = pkgs.writeTextFile {
name = "borgmatic-config.yaml";
text = lib.generators.toYAML {} {
source_directories = ["/mnt/longhorn/persistent/longhorn-backup"];
text = lib.generators.toYAML { } {
source_directories = [ "/mnt/longhorn/persistent/longhorn-backup" ];
repositories = [
{
@ -31,7 +27,8 @@
encryption_passcommand = "${pkgs.coreutils}/bin/cat ${config.sops.secrets."borg/borgPassphrase".path}";
};
};
in {
in
{
options.lab.backups = {
enable = lib.mkOption {
default = false;
@ -51,13 +48,13 @@ in {
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [borgbackup];
environment.systemPackages = with pkgs; [ borgbackup ];
# Converted from:
# https://github.com/borgmatic-collective/borgmatic/tree/84823dfb912db650936e3492f6ead7e0e0d32a0f/sample/systemd
systemd.services.borgmatic = {
description = "borgmatic backup";
wants = ["network-online.target"];
after = ["network-online.target"];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
unitConfig.ConditionACPower = true;
preStart = "${pkgs.coreutils}/bin/sleep 10s";
@ -78,7 +75,7 @@ in {
systemd.timers.borgmatic = {
description = "Run borgmatic backup";
wantedBy = ["timers.target"];
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*-*-* 3:00:00";
Persistent = true;
@ -87,8 +84,8 @@ in {
};
sops.secrets = {
"borg/borgPassphrase" = {};
"borg/borgbasePrivateKey" = {};
"borg/borgPassphrase" = { };
"borg/borgbasePrivateKey" = { };
};
};
}

View file

@ -1,8 +1,5 @@
{
lib,
config,
...
}: let
{ lib, config, ... }:
let
cfg = config.lab.data-sharing;
nfsShares = [
@ -16,12 +13,13 @@
nfsExports = lib.strings.concatLines (
builtins.map
(
share: "${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash) 127.0.0.1/8(rw,sync,no_subtree_check,no_root_squash) 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash)"
)
nfsShares
(share:
"${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash) 127.0.0.1/8(rw,sync,no_subtree_check,no_root_squash) 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash)"
)
nfsShares
);
in {
in
{
options.lab.data-sharing = {
enable = lib.mkOption {
default = false;

View file

@ -1,27 +1,17 @@
{
self,
pkgs,
config,
lib,
inputs,
machine,
...
}: {
imports =
[
./storage.nix
./backups.nix
./networking
./data-sharing.nix
./monitoring
./k3s
./tailscale.nix
machine.nixosModule
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.nix-snapshotter.nixosModules.nix-snapshotter
]
++ lib.lists.optional (machine.isRaspberryPi) inputs.nixos-hardware.nixosModules.raspberry-pi-4;
{ self, pkgs, config, lib, inputs, machine, ... }: {
imports = [
./storage.nix
./backups.nix
./networking
./data-sharing.nix
./monitoring
./k3s
./tailscale.nix
machine.nixosModule
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.nix-snapshotter.nixosModules.nix-snapshotter
] ++ lib.lists.optional (machine.isRaspberryPi) inputs.nixos-hardware.nixosModules.raspberry-pi-4;
config = {
time.timeZone = "Europe/Amsterdam";
@ -41,9 +31,7 @@
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = let
extraLocale = "nl_NL.UTF-8";
in {
extraLocaleSettings = let extraLocale = "nl_NL.UTF-8"; in {
LC_ADDRESS = extraLocale;
LC_IDENTIFICATION = extraLocale;
LC_MEASUREMENT = extraLocale;
@ -109,12 +97,12 @@
];
boot = lib.mkIf (! machine.isRaspberryPi) {
kernelModules = ["kvm-intel"];
extraModulePackages = [];
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
kernel.sysctl."fs.inotify.max_user_instances" = 256;
initrd = {
kernelModules = [];
kernelModules = [ ];
availableKernelModules = [
"ahci"

View file

@ -1,5 +1,5 @@
{kubenix, ...}: {
imports = [kubenix.modules.k8s];
{ kubenix, ... }: {
imports = [ kubenix.modules.k8s ];
kubernetes.resources.clusterRoleBindings.cluster-admins = {
roleRef = {
apiGroup = "rbac.authorization.k8s.io";

View file

@ -1,13 +1,8 @@
{
self,
inputs,
pkgs,
lib,
config,
...
}: let
{ self, inputs, pkgs, lib, config, ... }:
let
cfg = config.lab.k3s;
in {
in
{
options.lab.k3s = {
enable = lib.mkOption {
default = false;
@ -67,66 +62,68 @@ in {
address = "/run/nix-snapshotter/nix-snapshotter.sock";
};
plugins = let
k3s-cni-plugins = pkgs.buildEnv {
name = "k3s-cni-plugins";
paths = with pkgs; [
cni-plugins
cni-plugin-flannel
];
};
in {
"io.containerd.grpc.v1.cri" = {
stream_server_address = "127.0.0.1";
stream_server_port = "10010";
enable_selinux = false;
enable_unprivileged_ports = true;
enable_unprivileged_icmp = true;
disable_apparmor = true;
disable_cgroup = true;
restrict_oom_score_adj = true;
sandbox_image = "rancher/mirrored-pause:3.6";
containerd.snapshotter = "nix";
cni = {
conf_dir = "/var/lib/rancher/k3s/agent/etc/cni/net.d/";
bin_dir = "${k3s-cni-plugins}/bin";
plugins =
let
k3s-cni-plugins = pkgs.buildEnv {
name = "k3s-cni-plugins";
paths = with pkgs; [
cni-plugins
cni-plugin-flannel
];
};
};
in
{
"io.containerd.grpc.v1.cri" = {
stream_server_address = "127.0.0.1";
stream_server_port = "10010";
enable_selinux = false;
enable_unprivileged_ports = true;
enable_unprivileged_icmp = true;
disable_apparmor = true;
disable_cgroup = true;
restrict_oom_score_adj = true;
sandbox_image = "rancher/mirrored-pause:3.6";
containerd.snapshotter = "nix";
"io.containerd.transfer.v1.local".unpack_config = [
{
cni = {
conf_dir = "/var/lib/rancher/k3s/agent/etc/cni/net.d/";
bin_dir = "${k3s-cni-plugins}/bin";
};
};
"io.containerd.transfer.v1.local".unpack_config = [{
platform = "linux/amd64";
snapshotter = "nix";
}
];
};
}];
};
};
};
services = {
nix-snapshotter.enable = true;
k3s = let
serverFlagList = [
"--image-service-endpoint=unix:///run/nix-snapshotter/nix-snapshotter.sock"
"--snapshotter=overlayfs"
"--container-runtime-endpoint=unix:///run/containerd/containerd.sock"
"--tls-san=${config.networking.fqdn}"
"--disable=servicelb"
"--cluster-cidr=10.42.0.0/16,2001:cafe:42::/56"
"--service-cidr=10.43.0.0/16,2001:cafe:43::/112"
];
k3s =
let
serverFlagList = [
"--image-service-endpoint=unix:///run/nix-snapshotter/nix-snapshotter.sock"
"--snapshotter=overlayfs"
"--container-runtime-endpoint=unix:///run/containerd/containerd.sock"
"--tls-san=${config.networking.fqdn}"
"--disable=servicelb"
"--cluster-cidr=10.42.0.0/16,2001:cafe:42::/56"
"--service-cidr=10.43.0.0/16,2001:cafe:43::/112"
];
serverFlags = builtins.concatStringsSep " " serverFlagList;
in {
enable = true;
role = cfg.role;
tokenFile = config.sops.secrets."k3s/serverToken".path;
extraFlags = lib.mkIf (cfg.role == "server") (lib.mkForce serverFlags);
clusterInit = cfg.clusterInit;
serverAddr = lib.mkIf (! (cfg.serverAddr == null)) cfg.serverAddr;
};
serverFlags = builtins.concatStringsSep " " serverFlagList;
in
{
enable = true;
role = cfg.role;
tokenFile = config.sops.secrets."k3s/serverToken".path;
extraFlags = lib.mkIf (cfg.role == "server") (lib.mkForce serverFlags);
clusterInit = cfg.clusterInit;
serverAddr = lib.mkIf (! (cfg.serverAddr == null)) cfg.serverAddr;
};
# Required for Longhorn
openiscsi = {
@ -146,14 +143,11 @@ in {
k3s-bootstrap = lib.mkIf (cfg.role == "server") {
text = (
let
k3sBootstrapFile =
(inputs.kubenix.evalModules.x86_64-linux {
module = import ./bootstrap.nix;
})
.config
.kubernetes
.result;
in ''
k3sBootstrapFile = (inputs.kubenix.evalModules.x86_64-linux {
module = import ./bootstrap.nix;
}).config.kubernetes.result;
in
''
mkdir -p /var/lib/rancher/k3s/server/manifests
ln -sf ${k3sBootstrapFile} /var/lib/rancher/k3s/server/manifests/k3s-bootstrap.json
''
@ -172,16 +166,18 @@ in {
};
};
sops.secrets = let
keyPathBase = "/var/lib/rancher/k3s/server/tls";
in {
"k3s/serverToken" = {};
"k3s/keys/clientCAKey".path = "${keyPathBase}/client-ca.key";
"k3s/keys/requestHeaderCAKey".path = "${keyPathBase}/request-header-ca.key";
"k3s/keys/serverCAKey".path = "${keyPathBase}/server-ca.key";
"k3s/keys/serviceKey".path = "${keyPathBase}/service.key";
"k3s/keys/etcd/peerCAKey".path = "${keyPathBase}/etcd/peer-ca.key";
"k3s/keys/etcd/serverCAKey".path = "${keyPathBase}/etcd/server-ca.key";
};
sops.secrets =
let
keyPathBase = "/var/lib/rancher/k3s/server/tls";
in
{
"k3s/serverToken" = { };
"k3s/keys/clientCAKey".path = "${keyPathBase}/client-ca.key";
"k3s/keys/requestHeaderCAKey".path = "${keyPathBase}/request-header-ca.key";
"k3s/keys/serverCAKey".path = "${keyPathBase}/server-ca.key";
"k3s/keys/serviceKey".path = "${keyPathBase}/service.key";
"k3s/keys/etcd/peerCAKey".path = "${keyPathBase}/etcd/peer-ca.key";
"k3s/keys/etcd/serverCAKey".path = "${keyPathBase}/etcd/server-ca.key";
};
};
}

View file

@ -1,11 +1,8 @@
{
lib,
config,
machines,
...
}: let
{ lib, config, machines, ... }:
let
cfg = config.lab.monitoring;
in {
in
{
options = {
lab.monitoring = {
enable = lib.mkOption {
@ -21,9 +18,8 @@ in {
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts =
[config.services.prometheus.exporters.node.port]
++ lib.lists.optionals cfg.server.enable [80];
networking.firewall.allowedTCPPorts = [ config.services.prometheus.exporters.node.port ]
++ lib.lists.optionals cfg.server.enable [ 80 ];
services.prometheus = {
enable = cfg.server.enable;
@ -36,15 +32,12 @@ in {
scrapeConfigs = lib.mkIf cfg.server.enable (
let
generated =
lib.attrsets.mapAttrsToList
generated = lib.attrsets.mapAttrsToList
(name: machine: {
job_name = name;
static_configs = [
{
targets = ["${name}.dmz:${toString config.services.prometheus.exporters.node.port}"];
}
];
static_configs = [{
targets = [ "${name}.dmz:${toString config.services.prometheus.exporters.node.port}" ];
}];
})
machines;
@ -60,14 +53,12 @@ in {
password = "admin";
};
static_configs = [
{
targets = ["pikvm.dmz"];
}
];
static_configs = [{
targets = [ "pikvm.dmz" ];
}];
};
in
generated ++ [pikvm]
generated ++ [ pikvm ]
);
};

View file

@ -1,8 +1,4 @@
{
lib,
machine,
...
}: {
{ lib, machine, ... }: {
config = {
networking = {
domain = "dmz";

View file

@ -1,8 +1,5 @@
{
lib,
config,
...
}: let
{ lib, config, ... }:
let
cfg = config.lab.storage;
modules = [
{
@ -10,7 +7,7 @@
fileSystems."/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = ["noatime"];
options = [ "noatime" ];
};
};
}
@ -90,7 +87,7 @@
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = ["defaults"];
mountOptions = [ "defaults" ];
};
};
@ -148,7 +145,7 @@
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = ["defaults"];
mountOptions = [ "defaults" ];
};
};
};
@ -158,7 +155,8 @@
};
}
];
in {
in
{
imports = modules;
options.lab.storage = {

View file

@ -1,10 +1,8 @@
{
lib,
config,
...
}: let
{ lib, config, ... }:
let
cfg = config.lab.tailscale;
in {
in
{
options = {
lab.tailscale = {
enable = lib.mkEnableOption "tailscale";
@ -23,17 +21,15 @@ in {
useRoutingFeatures = "server";
openFirewall = true;
extraUpFlags =
[
"--accept-dns=false"
"--hostname=${config.networking.hostName}"
]
++ lib.lists.optional cfg.advertiseExitNode "--advertise-exit-node"
++ lib.lists.optional cfg.advertiseExitNode "--advertise-routes=192.168.30.0/24";
extraUpFlags = [
"--accept-dns=false"
"--hostname=${config.networking.hostName}"
] ++ lib.lists.optional cfg.advertiseExitNode "--advertise-exit-node"
++ lib.lists.optional cfg.advertiseExitNode "--advertise-routes=192.168.30.0/24";
};
sops.secrets."tailscale/authKey" = {};
sops.secrets."tailscale/authKey" = { };
systemd.network.wait-online.ignoredInterfaces = ["tailscale0"];
systemd.network.wait-online.ignoredInterfaces = [ "tailscale0" ];
};
}

View file

@ -1,26 +1,23 @@
{
self,
nixpkgs,
...
} @ inputs: let
{ self, nixpkgs, ... }@inputs:
let
deployArch = "x86_64-linux";
machines = self.machines.${deployArch};
mkNixosSystems = systemDef:
builtins.mapAttrs
(
name: machine:
(name: machine:
nixpkgs.lib.nixosSystem (systemDef name machine)
)
machines;
in {
)
machines;
in
{
nixosConfigurations = mkNixosSystems (name: machine: {
system = machine.arch;
specialArgs = {inherit self inputs machine machines;};
specialArgs = { inherit self inputs machine machines; };
modules = [
"${self}/modules"
{networking.hostName = name;}
{ networking.hostName = name; }
];
});
}

View file

@ -1,31 +1,23 @@
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
{ nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
createScript = {
name,
runtimeInputs,
scriptPath,
extraWrapperFlags ? "",
...
}: let
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
createScript = { name, runtimeInputs, scriptPath, extraWrapperFlags ? "", ... }:
let
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
pkgs.symlinkJoin {
inherit name;
paths = [script] ++ runtimeInputs;
buildInputs = [pkgs.makeWrapper];
paths = [ script ] ++ runtimeInputs;
buildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin ${extraWrapperFlags}";
};
in {
in
{
packages.bootstrap = createScript {
name = "bootstrap";
runtimeInputs = with pkgs; [sops coreutils nixos-anywhere];
runtimeInputs = with pkgs; [ sops coreutils nixos-anywhere ];
scriptPath = ./bootstrap.sh;
};
})

View file

@ -1,12 +1,9 @@
{
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
{ flake-utils, nixpkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ansible];
buildInputs = with pkgs; [ ansible ];
};
})

View file

@ -1,4 +0,0 @@
{...}: {
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
}

View file

@ -1,14 +1,14 @@
{
nixpkgs,
flake-utils,
...
}: let
systemAttrs = flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacypackages.${system};
lib = pkgs.lib;
in {
net = import ./net.nix lib;
});
{ nixpkgs, flake-utils, ... }:
let
systemAttrs = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacypackages.${system};
lib = pkgs.lib;
in
{
net = import ./net.nix lib;
});
nonSystemAttrs = {
globals = import ./globals.nix;
@ -16,4 +16,4 @@
allAttrs = systemAttrs // nonSystemAttrs;
in
allAttrs
allAttrs

File diff suppressed because it is too large Load diff