Apply nixfmt to the whole tree

This commit is contained in:
Greg Hellings
2024-11-18 21:22:32 -06:00
parent 18b7cddaaa
commit e7d1b0f7bd
34 changed files with 822 additions and 714 deletions
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "3.19.0"; {
arch = "amd64"; version = "3.19.0";
eol = false; arch = "amd64";
} { eol = false;
version = "3.20"; }
arch = "amd64"; {
eol = false; version = "3.20";
} ] arch = "amd64";
eol = false;
}
]
+7 -5
View File
@@ -1,5 +1,7 @@
[ { [
version = "rolling"; {
arch = "amd64"; version = "rolling";
eol = false; arch = "amd64";
} ] eol = false;
}
]
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
+7 -5
View File
@@ -1,5 +1,7 @@
[ { [
version = "7"; {
arch = "amd64"; version = "7";
eol = true; arch = "amd64";
} ] eol = true;
}
]
+25 -20
View File
@@ -1,20 +1,25 @@
[ { [
version = "9"; {
arch = "amd64"; version = "9";
eol = true; arch = "amd64";
} { eol = true;
version = "10"; }
arch = "amd64"; {
eol = true; version = "10";
} { arch = "amd64";
version = "11"; eol = true;
arch = "amd64"; }
eol = false; {
} { version = "11";
version = "12"; arch = "amd64";
arch = "amd64"; eol = false;
eol = false; }
exclude = [ {
"virtualbox-iso" version = "12";
]; arch = "amd64";
} ] eol = false;
exclude = [
"virtualbox-iso"
];
}
]
+11 -11
View File
@@ -1,13 +1,13 @@
{ {
almalinux = import ./almalinux; almalinux = import ./almalinux;
alpine = import ./alpine; alpine = import ./alpine;
archlinux = import ./archlinux; archlinux = import ./archlinux;
centos = import ./centos; centos = import ./centos;
centos-stream = import ./centos-stream; centos-stream = import ./centos-stream;
debian = import ./debian; debian = import ./debian;
fedora = import ./fedora; fedora = import ./fedora;
nixos = import ./nixos; nixos = import ./nixos;
opensuse = import ./opensuse; opensuse = import ./opensuse;
rockylinux = import ./rockylinux; rockylinux = import ./rockylinux;
ubuntu = import ./ubuntu; ubuntu = import ./ubuntu;
} }
+32 -25
View File
@@ -1,25 +1,32 @@
[ { [
version = "37"; {
arch = "amd64"; version = "37";
eol = true; arch = "amd64";
} { eol = true;
version = "38"; }
arch = "amd64"; {
eol = true; version = "38";
} { arch = "amd64";
version = "39"; eol = true;
arch = "amd64"; }
eol = false; {
} { version = "39";
version = "40"; arch = "amd64";
arch = "amd64"; eol = false;
eol = false; }
} { {
version = "41"; version = "40";
arch = "amd64"; arch = "amd64";
eol = false; eol = false;
} { }
version = "rawhide"; {
arch = "amd64"; version = "41";
eol = false; arch = "amd64";
} ] eol = false;
}
{
version = "rawhide";
arch = "amd64";
eol = false;
}
]
+67 -59
View File
@@ -1,67 +1,75 @@
{config, pkgs, lib, ...}: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "23.05"; system.stateVersion = "23.05";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminux16"; font = "Lat2-Terminux16";
keyMap = lib.mkForce "us"; keyMap = lib.mkForce "us";
useXkbConfig = true; useXkbConfig = true;
}; };
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
settings = { settings = {
experimental-features = "nix-command flakes"; experimental-features = "nix-command flakes";
}; };
}; };
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-23.05"; nixstable.url = "github:nixos/nixpkgs/nixos-23.05";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, self, ... }@inputs:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+5 -5
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
x11 = false; x11 = false;
}; };
} }
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+67 -59
View File
@@ -1,67 +1,75 @@
{config, pkgs, lib, ...}: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "23.11"; system.stateVersion = "23.11";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminux16"; font = "Lat2-Terminux16";
keyMap = lib.mkForce "us"; keyMap = lib.mkForce "us";
useXkbConfig = true; useXkbConfig = true;
}; };
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
settings = { settings = {
experimental-features = "nix-command flakes"; experimental-features = "nix-command flakes";
}; };
}; };
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-23.11"; nixstable.url = "github:nixos/nixpkgs/nixos-23.11";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, self, ... }@inputs:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+5 -5
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
x11 = false; x11 = false;
}; };
} }
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+67 -59
View File
@@ -1,67 +1,75 @@
{config, pkgs, lib, ...}: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "24.05"; system.stateVersion = "24.05";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminux16"; font = "Lat2-Terminux16";
keyMap = lib.mkForce "us"; keyMap = lib.mkForce "us";
useXkbConfig = true; useXkbConfig = true;
}; };
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
settings = { settings = {
experimental-features = "nix-command flakes"; experimental-features = "nix-command flakes";
}; };
}; };
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-24.05"; nixstable.url = "github:nixos/nixpkgs/nixos-24.05";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, self, ... }@inputs:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+4 -4
View File
@@ -1,6 +1,6 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
}; };
} }
+2 -2
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+17 -13
View File
@@ -1,13 +1,17 @@
[ { [
version = "23.05"; {
arch = "amd64"; version = "23.05";
eol = true; arch = "amd64";
} { eol = true;
version = "23.11"; }
arch = "amd64"; {
eol = true; version = "23.11";
} { arch = "amd64";
version = "24.05"; eol = true;
arch = "amd64"; }
eol = false; {
} ] version = "24.05";
arch = "amd64";
eol = false;
}
]
+22 -17
View File
@@ -1,17 +1,22 @@
[ { [
version = "15.5"; {
arch = "amd64"; version = "15.5";
eol = false; arch = "amd64";
} { eol = false;
version = "15.6"; }
arch = "amd64"; {
eol = false; version = "15.6";
} { arch = "amd64";
version = "16.0"; eol = false;
arch = "amd64"; }
eol = true; # Not yet released, and bugged at the moment {
} { version = "16.0";
version = "tumbleweed"; arch = "amd64";
arch = "amd64"; eol = true; # Not yet released, and bugged at the moment
eol = false; }
} ] {
version = "tumbleweed";
arch = "amd64";
eol = false;
}
]
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
+32 -25
View File
@@ -1,25 +1,32 @@
[ { [
version = "18.04"; {
arch = "amd64"; version = "18.04";
eol = true; arch = "amd64";
} { eol = true;
version = "20.04"; }
arch = "amd64"; {
eol = false; version = "20.04";
} { arch = "amd64";
version = "22.04"; eol = false;
arch = "amd64"; }
eol = false; {
} { version = "22.04";
version = "23.10"; arch = "amd64";
arch = "amd64"; eol = false;
eol = true; }
} { {
version = "24.04"; version = "23.10";
arch = "amd64"; arch = "amd64";
eol = false; eol = true;
} { }
version = "24.10"; {
arch = "amd64"; version = "24.04";
eol = false; arch = "amd64";
} ] eol = false;
}
{
version = "24.10";
arch = "amd64";
eol = false;
}
]
Generated
+1 -52
View File
@@ -37,21 +37,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-root": {
"locked": {
"lastModified": 1713493429,
"narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=",
"owner": "srid",
"repo": "flake-root",
"rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@@ -114,22 +99,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1708475490,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"process-compose": { "process-compose": {
"locked": { "locked": {
"lastModified": 1718031437, "lastModified": 1718031437,
@@ -149,10 +118,8 @@
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-root": "flake-root",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"process-compose": "process-compose", "process-compose": "process-compose"
"treefmt-nix": "treefmt-nix"
} }
}, },
"systems": { "systems": {
@@ -169,24 +136,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1718522839,
"narHash": "sha256-ULzoKzEaBOiLRtjeY3YoGFJMwWSKRYOic6VNw2UyTls=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "68eb1dc333ce82d0ab0c0357363ea17c31ea1f81",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",
+275 -199
View File
@@ -1,205 +1,281 @@
# github.com/brianmcgee has lots of great ideas for going above and beyond for this # github.com/brianmcgee has lots of great ideas for going above and beyond for this
{ {
description = "Greg's homepage"; description = "Greg's homepage";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell"; devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root"; process-compose.url = "github:Platonic-Systems/process-compose-flake";
process-compose.url = "github:Platonic-Systems/process-compose-flake"; };
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = { devshell, flake-parts, flake-root, process-compose, treefmt-nix, nixpkgs, ... }@inputs: let outputs =
lib = nixpkgs.lib; { flake-parts, nixpkgs, ... }@inputs:
providers = [ let
"qemu" lib = nixpkgs.lib;
"virtualbox-iso" providers = [
"hyperv-iso" "qemu"
]; "virtualbox-iso"
distros = import ./distros; "hyperv-iso"
# Inserts the distro name into each element in the list ];
insertNames = lib.attrsets.mapAttrsToList (distro: val: (builtins.map (x: x // { inherit distro; }) val)) distros; distros = import ./distros;
# Flattens all the distros into a single list # Inserts the distro name into each element in the list
flat = lib.lists.flatten insertNames; insertNames = lib.attrsets.mapAttrsToList (
# Combines providers list with flattened list distro: val: (builtins.map (x: x // { inherit distro; }) val)
withProviders = lib.attrsets.mapCartesianProduct ) distros;
({d, provider}: d // { inherit provider; }) # Flattens all the distros into a single list
{ d = flat; provider = providers; }; flat = lib.lists.flatten insertNames;
active = builtins.filter (x: (x?eol) && (!x.eol)) withProviders; # Combines providers list with flattened list
name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}"; withProviders = lib.attrsets.mapCartesianProduct ({ d, provider }: d // { inherit provider; }) {
distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl"; d = flat;
cmd = d: '' provider = providers;
# This is a workaround for a goofy behavior in CI };
if [ -e "''${PACKER_CONFIG_DIR}" ]; then active = builtins.filter (x: (x ? eol) && (!x.eol)) withProviders;
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}";
fi distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl";
packer init sources cmd = d: ''
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}''; # This is a workaround for a goofy behavior in CI
in flake-parts.lib.mkFlake { inherit inputs; } if [ -e "''${PACKER_CONFIG_DIR}" ]; then
{ find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
imports = [ fi
inputs.devshell.flakeModule packer init sources
inputs.flake-root.flakeModule packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}'';
inputs.treefmt-nix.flakeModule in
]; flake-parts.lib.mkFlake { inherit inputs; } {
flake = { imports = [
# Universal things inputs.devshell.flakeModule
}; inputs.flake-root.flakeModule
systems = [ inputs.treefmt-nix.flakeModule
"x86_64-linux" ];
"aarch64-linux" flake = {
]; # Universal things
perSystem = { config, pkgs, self', system, ... }: };
{ systems = [
_module.args.pkgs = import inputs.nixpkgs { "x86_64-linux"
inherit system; "aarch64-linux"
config.allowUnfree = true; ];
}; perSystem =
# https://numtide.github.io/devshell/intro.html {
devshells.default = { pkgs,
# These commands will be shown in the motd that users read self',
# upon entering the shell system,
commands = [ { ...
package = self'.packages.cache; }@inputs':
category = "utils"; {
help = "Downloads ISO files and adds them to the S3 bucket"; _module.args.pkgs = import inputs.nixpkgs {
} { inherit system;
package = self'.packages.generate; config.allowUnfree = true;
category = "utils"; };
help = "Generate dynamic HCL files"; # https://numtide.github.io/devshell/intro.html
} { devshells.default = {
package = self'.packages.shellcheck; # These commands will be shown in the motd that users read
category = "utils"; # upon entering the shell
help = "Run shellchecks"; commands =
} { [
package = self'.packages.validate; {
category = "utils"; package = self'.packages.cache;
help = "Validate all the files"; category = "utils";
} { help = "Downloads ISO files and adds them to the S3 bucket";
package = pkgs.vagrant; }
category = "utils"; {
help = "Vagrant to help with testing"; package = self'.packages.generate;
} ] ++ (builtins.map (d: { package = self'.packages."build${name d}"; category = "builds"; }) withProviders); category = "utils";
env = [{ help = "Generate dynamic HCL files";
name = "EFI_DIR"; }
value = "${pkgs.OVMF.fd}/FV/"; {
} { package = self'.packages.shellcheck;
name = "PACKER_CONFIG_DIR"; category = "utils";
value = "./packer_config"; help = "Run shellchecks";
} { }
name = "STORAGE_URL"; {
value = "http://s3.thehellings.lan:9000"; package = self'.packages.validate;
} ]; category = "utils";
}; help = "Validate all the files";
}
{
package = pkgs.vagrant;
category = "utils";
help = "Vagrant to help with testing";
}
]
++ (builtins.map (d: {
package = self'.packages."build${name d}";
category = "builds";
}) withProviders);
env = [
{
name = "EFI_DIR";
value = "${pkgs.OVMF.fd}/FV/";
}
{
name = "PACKER_CONFIG_DIR";
value = "./packer_config";
}
{
name = "STORAGE_URL";
value = "http://s3.thehellings.lan:9000";
}
];
};
# This is not special, this is just flakes # This is not special, this is just flakes
packages = let packages =
base = { let
runtimeInputs = with pkgs; [ base = {
cdrtools runtimeInputs = with pkgs; [
findutils cdrtools
packer findutils
qemu_full packer
vagrant qemu_full
xorriso vagrant
]; xorriso
}; ];
build = d: let };
vp = x: if x.provider == "qemu" then "libvirt" build =
else if x.provider == "virtualbox-iso" then "virtualbox" d:
else if x.provider == "hyperv-iso" then "hyperv" let
else "unknown"; vp =
in pkgs.writeShellApplication (base // { x:
name = "build${name d}"; if x.provider == "qemu" then
text = '' "libvirt"
set -x else if x.provider == "virtualbox-iso" then
${cmd d} -except=upload -var headless=false sources/ "virtualbox"
vagrant box add --provider ${vp d} ./output/${vp d}/${d.distro}-${d.version}.box --name test_box --force else if x.provider == "hyperv-iso" then
''; "hyperv"
}); else
cibuild = d: pkgs.writeShellApplication (base // { "unknown";
name = "ci${name d}"; in
text = '' pkgs.writeShellApplication (
set -x base
${cmd d} -except=upload sources/ // {
''; name = "build${name d}";
}); text = ''
upload = d: pkgs.writeShellApplication (base // { set -x
name = "upload${name d}"; ${cmd d} -except=upload -var headless=false sources/
text = '' vagrant box add --provider ${vp d} ./output/${vp d}/${d.distro}-${d.version}.box --name test_box --force
set -x '';
${cmd d} sources/ }
''; );
}); cibuild =
builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) {} withProviders; d:
uploads = lib.lists.foldr (d: acc: acc // { "upload${name d}" = (upload d); }) {} withProviders; pkgs.writeShellApplication (
cibuilds = lib.lists.foldr (d: acc: acc // { "ci${name d}" = (cibuild d); }) {} withProviders; base
qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = (name d); }) (builtins.filter (x: x.provider == "qemu") active)); // {
vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = (name d); }) (builtins.filter (x: x.provider == "virtualbox-iso") active)); name = "ci${name d}";
hyperv_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "hyperv-iso") active)); text = ''
in builds // uploads // cibuilds // { set -x
continue = pkgs.writeText "continue.yml" ${cmd d} -except=upload sources/
(builtins.replaceStrings ["QEMU_MATRIX" "VBOX_MATRIX" "HYPERV_MATRIX"] [qemu_list vbox_list hyperv_list] '';
(builtins.readFile ./.gitlab-ci-build.yml.in) }
); );
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; }; upload =
validate = pkgs.callPackage (import ./nix/validate.nix) {}; d:
cache-restore = pkgs.writeShellApplication { pkgs.writeShellApplication (
name = "cache-restore"; base
runtimeInputs = with pkgs; [ // {
jq name = "upload${name d}";
minio-client text = ''
packer set -x
]; ${cmd d} sources/
text = builtins.readFile ./cache-restore.sh; '';
}; }
generate = pkgs.writeShellApplication { );
name = "generate"; builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) { } withProviders;
runtimeInputs = with pkgs; [ uploads = lib.lists.foldr (d: acc: acc // { "upload${name d}" = (upload d); }) { } withProviders;
bash cibuilds = lib.lists.foldr (d: acc: acc // { "ci${name d}" = (cibuild d); }) { } withProviders;
coreutils qemu_list = builtins.toJSON (
curl builtins.map (d: { buildcmd = (name d); }) (builtins.filter (x: x.provider == "qemu") active)
jq );
pup vbox_list = builtins.toJSON (
]; builtins.map (d: { buildcmd = (name d); }) (
text = '' builtins.filter (x: x.provider == "virtualbox-iso") active
shopt -s globstar )
for vars in distros/**/*.pkrvars.hcl.sh; do );
bash "./''${vars}" hyperv_list = builtins.toJSON (
done builtins.map (d: { distro = distroFile d; }) (
set -x builtins.filter (x: x.provider == "hyperv-iso") active
echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env )
''; );
}; in
shellcheck = pkgs.writeShellApplication { builds
name = "shellcheck"; // uploads
runtimeInputs = with pkgs; [ // cibuilds
shellcheck // {
]; continue = pkgs.writeText "continue.yml" (
text = '' builtins.replaceStrings
scripts=() [
shopt -s globstar "QEMU_MATRIX"
for f in **/*.sh; do "VBOX_MATRIX"
scripts+=("$f") "HYPERV_MATRIX"
done ]
shellcheck -e SC2239 "''${scripts[@]}" [
''; qemu_list
}; vbox_list
}; hyperv_list
]
(builtins.readFile ./.gitlab-ci-build.yml.in)
);
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; };
validate = pkgs.callPackage (import ./nix/validate.nix) { };
cache-restore = pkgs.writeShellApplication {
name = "cache-restore";
runtimeInputs = with pkgs; [
jq
minio-client
packer
];
text = builtins.readFile ./cache-restore.sh;
};
generate = pkgs.writeShellApplication {
name = "generate";
runtimeInputs = with pkgs; [
bash
coreutils
curl
jq
pup
];
text = ''
shopt -s globstar
for vars in distros/**/*.pkrvars.hcl.sh; do
bash "./''${vars}"
done
set -x
echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env
'';
};
shellcheck = pkgs.writeShellApplication {
name = "shellcheck";
runtimeInputs = with pkgs; [
shellcheck
];
text = ''
scripts=()
shopt -s globstar
for f in **/*.sh; do
scripts+=("$f")
done
shellcheck -e SC2239 "''${scripts[@]}"
'';
};
};
# https://numtide.github.io/treefmt/ checks = {
treefmt.config = { pre-commit = inputs.hooks.lib.${inputs'.system}.run {
inherit (config.flake-root) projectRootFile; src = ./.;
package = pkgs.treefmt; hooks = {
check-added-large-files.enable = true;
programs = { check-case-conflicts.enable = true;
deadnix.enable = true; check-merge-conflicts.enable = true;
}; check-symlinks.enable = true;
deadnix.enable = true;
settings.formatter = { end-of-file-fixer.enable = true;
}; fix-byte-order-marker.enable = true;
}; mixed-line-endings.enable = true;
}; nixfmt-rfc-style.enable = true;
}; trim-trailing-whitespace.enable = true;
};
};
};
};
};
} }
+40 -37
View File
@@ -1,44 +1,47 @@
{ {
writeShellApplication, writeShellApplication,
active, active,
distroFile, distroFile,
curl, curl,
minio-client, minio-client,
packer, packer,
... ...
}: }:
let let
inherit (builtins) concatStringsSep map; inherit (builtins) concatStringsSep map;
in writeShellApplication { in
name = "cache-isos"; writeShellApplication {
runtimeInputs = [ name = "cache-isos";
curl runtimeInputs = [
minio-client curl
packer minio-client
]; packer
text = '' ];
push="''${1:-yes}" text =
if [ "$push" == "yes" ]; then ''
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" push="''${1:-yes}"
fi if [ "$push" == "yes" ]; then
mkdir -p cache mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
'' + (concatStringsSep "\n" ( fi
map (d: '' mkdir -p cache
url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) ''
sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) + (concatStringsSep "\n" (
distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) map (d: ''
# shellcheck disable=SC2143 url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url" distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
if [ "$push" == "yes" ]; then # shellcheck disable=SC2143
mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso" if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then
fi curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url"
else if [ "$push" == "yes" ]; then
echo "Skipping ${d.distro} - cache/$sha.iso" mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso"
fi fi
'') active else
)); echo "Skipping ${d.distro} - cache/$sha.iso"
fi
'') active
));
} }
+19 -19
View File
@@ -1,23 +1,23 @@
{ {
writeShellApplication, writeShellApplication,
findutils, findutils,
packer, packer,
... ...
}: }:
writeShellApplication { writeShellApplication {
name = "validate"; name = "validate";
runtimeInputs = [ runtimeInputs = [
findutils findutils
packer packer
]; ];
text = '' text = ''
shopt -s globstar shopt -s globstar
if [ -e "''${PACKER_CONFIG_DIR}" ]; then if [ -e "''${PACKER_CONFIG_DIR}" ]; then
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
fi fi
packer init sources packer init sources
for vars in distros/**/*.pkrvars.hcl; do for vars in distros/**/*.pkrvars.hcl; do
packer validate -except=upload "-var-file=''${vars}" sources/ packer validate -except=upload "-var-file=''${vars}" sources/
done done
''; '';
} }