Compare commits

..

7 commits

11 changed files with 371 additions and 387 deletions

View file

@ -14,11 +14,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1723293904, "lastModified": 1722339003,
"narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=", "narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=",
"owner": "ryantm", "owner": "ryantm",
"repo": "agenix", "repo": "agenix",
"rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41", "rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -299,11 +299,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1724299755, "lastModified": 1722924007,
"narHash": "sha256-P5zMA17kD9tqiqMuNXwupkM7buM3gMNtoZ1VuJTRDE4=", "narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "a8968d88e5a537b0491f68ce910749cd870bdbef", "rev": "91010a5613ffd7ee23ee9263213157a1c422b705",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -330,11 +330,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1724242322, "lastModified": 1722869614,
"narHash": "sha256-HMpK7hNjhEk4z5SFg5UtxEio9OWFocHdaQzCfW1pE7w=", "narHash": "sha256-7ojM1KSk3mzutD7SkrdSflHXEujPvW1u7QuqWoTLXQU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "224042e9a3039291f22f4f2ded12af95a616cca0", "rev": "883180e6550c1723395a3a342f830bfc5c371f6b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -519,11 +519,11 @@
}, },
"unstable": { "unstable": {
"locked": { "locked": {
"lastModified": 1724224976, "lastModified": 1722813957,
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -79,25 +79,14 @@
master = import inputs.master { inherit system; }; master = import inputs.master { inherit system; };
}; };
packages = packages = let
let
nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { }; nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { };
testDir = builtins.attrNames (builtins.readDir ./tests); testDir = builtins.attrNames (builtins.readDir ./tests);
testFiles = builtins.filter (n: builtins.match "^.*.nix$" n != null) testDir; testFiles = builtins.filter (n: builtins.match "^.*.nix$" n != null) testDir;
in in builtins.listToAttrs (map (x: {
builtins.listToAttrs (
map (x: {
name = "test-${lib.strings.removeSuffix ".nix" x}"; name = "test-${lib.strings.removeSuffix ".nix" x}";
value = nixos-lib.runTest ( value = nixos-lib.runTest (import (./tests + "/${x}") { inherit self; inherit pkgs; inherit lib; inherit config; });
import (./tests + "/${x}") { }) testFiles);
inherit self;
inherit pkgs;
inherit lib;
inherit config;
}
);
}) testFiles
);
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [

View file

@ -7,16 +7,11 @@
}: }:
{ {
options.pub-solar-os.backups = { options.pub-solar-os.backups = {
stores = stores = with lib; mkOption {
with lib;
mkOption {
description = '' description = ''
Periodic backups to create with Restic. Periodic backups to create with Restic.
''; '';
type = types.attrsOf ( type = types.attrsOf (types.submodule ({ name, ... }: {
types.submodule (
{ name, ... }:
{
options = { options = {
passwordFile = mkOption { passwordFile = mkOption {
type = types.str; type = types.str;
@ -35,9 +30,7 @@
example = "sftp:backup@192.168.1.100:/backups/${name}"; example = "sftp:backup@192.168.1.100:/backups/${name}";
}; };
}; };
} }));
)
);
default = { }; default = { };
example = { example = {
@ -48,16 +41,11 @@
}; };
}; };
backups = backups = with lib; mkOption {
with lib;
mkOption {
description = '' description = ''
Periodic backups to create with Restic. Periodic backups to create with Restic.
''; '';
type = types.attrsOf ( type = types.attrsOf (types.submodule ({ name, ... }: {
types.submodule (
{ name, ... }:
{
options = { options = {
paths = mkOption { paths = mkOption {
# This is nullable for legacy reasons only. We should consider making it a pure listOf # This is nullable for legacy reasons only. We should consider making it a pure listOf
@ -124,7 +112,9 @@
description = '' description = ''
Extra arguments passed to restic backup. Extra arguments passed to restic backup.
''; '';
example = [ "--exclude-file=/etc/nixos/restic-ignore" ]; example = [
"--exclude-file=/etc/nixos/restic-ignore"
];
}; };
extraOptions = mkOption { extraOptions = mkOption {
@ -133,7 +123,9 @@
description = '' description = ''
Extra extended options to be passed to the restic --option flag. Extra extended options to be passed to the restic --option flag.
''; '';
example = [ "sftp.command='ssh backup@192.168.1.100 -i /home/user/.ssh/id_rsa -s sftp'" ]; example = [
"sftp.command='ssh backup@192.168.1.100 -i /home/user/.ssh/id_rsa -s sftp'"
];
}; };
initialize = mkOption { initialize = mkOption {
@ -175,7 +167,9 @@
description = '' description = ''
A list of options for 'restic check'. A list of options for 'restic check'.
''; '';
example = [ "--with-cache" ]; example = [
"--with-cache"
];
}; };
dynamicFilesFrom = mkOption { dynamicFilesFrom = mkOption {
@ -217,9 +211,7 @@
''; '';
}; };
}; };
} }));
)
);
default = { }; default = { };
example = { example = {
localbackup = { localbackup = {
@ -242,22 +234,20 @@
}; };
config = { config = {
services.restic.backups = services.restic.backups = let
let
stores = config.pub-solar-os.backups.stores; stores = config.pub-solar-os.backups.stores;
backups = config.pub-solar-os.backups.backups; backups = config.pub-solar-os.backups.backups;
storeNames = builtins.attrNames stores; storeNames = builtins.attrNames stores;
backupNames = builtins.attrNames backups; backupNames = builtins.attrNames backups;
createBackups = createBackups = backupName: map
backupName: (storeName: {
map (storeName: {
name = "${backupName}-${storeName}"; name = "${backupName}-${storeName}";
value = stores."${storeName}" // backups."${backupName}"; value = stores."${storeName}" // backups."${backupName}";
}) storeNames; })
storeNames;
in in builtins.listToAttrs (lib.lists.flatten (map createBackups backupNames));
builtins.listToAttrs (lib.lists.flatten (map createBackups backupNames));
}; };
} }

View file

@ -6,7 +6,9 @@
... ...
}: }:
{ {
nixpkgs.config = lib.mkDefault { allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ ]; }; nixpkgs.config = lib.mkDefault {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ ];
};
nix = { nix = {
# Use default version alias for nix package # Use default version alias for nix package

View file

@ -42,7 +42,9 @@
}; };
}; };
nixpkgs.config = lib.mkDefault { permittedInsecurePackages = [ "keycloak-23.0.6" ]; }; nixpkgs.config = lib.mkDefault {
permittedInsecurePackages = [ "keycloak-23.0.6" ];
};
# keycloak # keycloak
services.keycloak = { services.keycloak = {

View file

@ -4,10 +4,8 @@
lib, lib,
config, config,
... ...
}: }: let
let in {
in
{
name = "keycloak"; name = "keycloak";
hostPkgs = pkgs; hostPkgs = pkgs;
@ -44,7 +42,9 @@ in
./support/global.nix ./support/global.nix
]; ];
systemd.tmpfiles.rules = [ "f /tmp/dbf 1777 root root 10d password" ]; systemd.tmpfiles.rules = [
"f /tmp/dbf 1777 root root 10d password"
];
virtualisation.memorySize = 4096; virtualisation.memorySize = 4096;
@ -65,9 +65,7 @@ in
enableOCR = true; enableOCR = true;
testScript = testScript = {nodes, ...}: let
{ nodes, ... }:
let
user = nodes.client.users.users.${nodes.client.pub-solar-os.authentication.username}; user = nodes.client.users.users.${nodes.client.pub-solar-os.authentication.username};
#uid = toString user.uid; #uid = toString user.uid;
bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u ${user.name})/bus"; bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u ${user.name})/bus";
@ -75,8 +73,7 @@ in
su = command: "su - ${user.name} -c '${command}'"; su = command: "su - ${user.name} -c '${command}'";
gseval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; gseval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval";
wmClass = su "${gdbus} ${gseval} global.display.focus_window.wm_class"; wmClass = su "${gdbus} ${gseval} global.display.focus_window.wm_class";
in in ''
''
start_all() start_all()
nachtigall.wait_for_unit("system.slice") nachtigall.wait_for_unit("system.slice")

View file

@ -3,11 +3,14 @@
lib, lib,
config, config,
... ...
}: }: {
{ imports = [
imports = [ ./global.nix ]; ./global.nix
];
systemd.tmpfiles.rules = [ "f /tmp/step-ca-intermediate-pw 1777 root root 10d password" ]; systemd.tmpfiles.rules = [
"f /tmp/step-ca-intermediate-pw 1777 root root 10d password"
];
networking.interfaces.eth0.ipv4.addresses = [ networking.interfaces.eth0.ipv4.addresses = [
{ {
@ -16,8 +19,7 @@
} }
]; ];
services.step-ca = services.step-ca = let
let
certificates = pkgs.stdenv.mkDerivation { certificates = pkgs.stdenv.mkDerivation {
name = "certificates"; name = "certificates";
src = ./step; src = ./step;
@ -27,8 +29,7 @@
cp -r secrets $out/ cp -r secrets $out/
''; '';
}; };
in in {
{
enable = true; enable = true;
openFirewall = true; openFirewall = true;
intermediatePasswordFile = "/tmp/step-ca-intermediate-pw"; intermediatePasswordFile = "/tmp/step-ca-intermediate-pw";

View file

@ -5,7 +5,9 @@
... ...
}: }:
{ {
imports = [ ./global.nix ]; imports = [
./global.nix
];
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true; services.xserver.displayManager.gdm.enable = true;

View file

@ -3,13 +3,14 @@
lib, lib,
config, config,
... ...
}: }: {
{
pub-solar-os.networking.domain = "test.pub.solar"; pub-solar-os.networking.domain = "test.pub.solar";
security.acme.defaults.server = "https://ca.${config.pub-solar-os.networking.domain}/acme/acme/directory"; security.acme.defaults.server = "https://ca.${config.pub-solar-os.networking.domain}/acme/acme/directory";
security.pki.certificates = [ (builtins.readFile ./step/certs/root_ca.crt) ]; security.pki.certificates = [
(builtins.readFile ./step/certs/root_ca.crt)
];
services.openssh = { services.openssh = {
enable = true; enable = true;
@ -23,12 +24,10 @@
security.pam.services.sshd.allowNullPassword = true; security.pam.services.sshd.allowNullPassword = true;
virtualisation.forwardPorts = virtualisation.forwardPorts = let
let
address = (builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address; address = (builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address;
lastAddressPart = builtins.elemAt (lib.strings.splitString "." address) 3; lastAddressPart = builtins.elemAt (lib.strings.splitString "." address) 3;
in in [
[
{ {
from = "host"; from = "host";
host.port = 2000 + (lib.strings.toInt lastAddressPart); host.port = 2000 + (lib.strings.toInt lastAddressPart);

View file

@ -2,7 +2,9 @@
"federatedRoots": null, "federatedRoots": null,
"address": ":443", "address": ":443",
"insecureAddress": "", "insecureAddress": "",
"dnsNames": ["ca.test.pub.solar"], "dnsNames": [
"ca.test.pub.solar"
],
"logger": { "logger": {
"format": "text" "format": "text"
}, },