2023-12-23 06:49:01 +01:00
|
|
|
{
|
2023-12-23 07:39:10 +01:00
|
|
|
description = "NixOS configuration for RAD-Development Servers";
|
2023-12-23 06:49:01 +01:00
|
|
|
|
2024-02-01 16:50:14 -05:00
|
|
|
nixConfig = {
|
2024-02-17 15:39:35 +01:00
|
|
|
substituters = [
|
2024-02-18 06:11:47 +01:00
|
|
|
"https://cache.nixos.org/?priority=1&want-mass-query=true"
|
2024-04-29 19:56:40 -04:00
|
|
|
"https://attic.alicehuston.xyz/cache-nix-dot?priority=4&want-mass-query=true"
|
|
|
|
"https://cache.alicehuston.xyz/?priority=5&want-mass-query=true"
|
2024-02-18 06:11:47 +01:00
|
|
|
"https://nix-community.cachix.org/?priority=10&want-mass-query=true"
|
2024-02-17 15:39:35 +01:00
|
|
|
];
|
|
|
|
trusted-substituters = [
|
|
|
|
"https://cache.nixos.org"
|
2024-04-29 19:56:40 -04:00
|
|
|
"https://attic.alicehuston.xyz/cache-nix-dot"
|
|
|
|
"https://cache.alicehuston.xyz"
|
2024-02-17 15:39:35 +01:00
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
];
|
|
|
|
trusted-public-keys = [
|
|
|
|
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
|
|
|
"cache.alicehuston.xyz:SJAm8HJVTWUjwcTTLAoi/5E1gUOJ0GWum2suPPv7CUo=%"
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
2024-03-24 13:08:42 -04:00
|
|
|
"cache-nix-dot:0hp/F6mUJXNyZeLBPNBjmyEh8gWsNVH+zkuwlWMmwXg="
|
2024-02-17 15:39:35 +01:00
|
|
|
];
|
2024-04-01 18:26:03 -04:00
|
|
|
trusted-users = [ "root" ];
|
2024-02-01 16:50:14 -05:00
|
|
|
};
|
|
|
|
|
2023-12-23 06:49:01 +01:00
|
|
|
inputs = {
|
2024-04-03 01:20:56 -04:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
2024-03-24 14:21:28 -04:00
|
|
|
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11";
|
2024-02-01 16:50:14 -05:00
|
|
|
systems.url = "github:nix-systems/default";
|
2024-02-02 22:54:36 +01:00
|
|
|
nix-index-database = {
|
|
|
|
url = "github:Mic92/nix-index-database";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2024-02-02 06:12:49 +01:00
|
|
|
nix = {
|
2024-02-02 07:13:24 +01:00
|
|
|
url = "github:NixOS/nix/latest-release";
|
2024-02-02 06:12:49 +01:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2024-01-01 12:41:32 -05:00
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
|
|
|
inputs.systems.follows = "systems";
|
|
|
|
};
|
|
|
|
|
2024-02-02 05:20:43 +01:00
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2023-12-24 18:48:52 +01:00
|
|
|
nixos-modules = {
|
|
|
|
url = "github:SuperSandro2000/nixos-modules";
|
2024-01-08 16:24:53 +01:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
};
|
2023-12-24 18:48:52 +01:00
|
|
|
};
|
|
|
|
|
2023-12-25 03:39:20 +01:00
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2023-12-23 06:49:01 +01:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
2023-12-24 18:48:52 +01:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
2024-03-24 14:21:28 -04:00
|
|
|
nixpkgs-stable.follows = "nixpkgs-stable";
|
2023-12-24 18:48:52 +01:00
|
|
|
};
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
2024-01-02 16:30:08 +01:00
|
|
|
|
2024-01-01 12:41:32 -05:00
|
|
|
nix-pre-commit = {
|
|
|
|
url = "github:jmgilman/nix-pre-commit";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
2024-03-24 13:08:42 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-24 14:21:28 -04:00
|
|
|
wired-notify = {
|
|
|
|
url = "github:Toqozz/wired-notify";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
rust-overlay.follows = "rust-overlay";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs = {
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nixos-hardware = {
|
|
|
|
url = "github:NixOS/nixos-hardware";
|
|
|
|
};
|
|
|
|
|
2024-03-24 13:08:42 -04:00
|
|
|
attic = {
|
|
|
|
url = "github:zhaofengli/attic";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
2024-01-01 12:41:32 -05:00
|
|
|
};
|
|
|
|
};
|
2024-04-16 23:25:52 -04:00
|
|
|
|
|
|
|
hyprland-contrib = {
|
|
|
|
url = "github:hyprwm/contrib";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
|
|
|
|
2024-03-03 18:06:28 -05:00
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
|
|
|
nix,
|
|
|
|
home-manager,
|
|
|
|
nix-pre-commit,
|
2024-03-24 14:21:28 -04:00
|
|
|
nixos-hardware,
|
2024-03-03 18:06:28 -05:00
|
|
|
nixos-modules,
|
|
|
|
nixpkgs,
|
|
|
|
sops-nix,
|
2024-03-24 14:21:28 -04:00
|
|
|
wired-notify,
|
2024-03-03 18:06:28 -05:00
|
|
|
...
|
|
|
|
}@inputs:
|
2023-12-27 10:03:13 +01:00
|
|
|
let
|
2024-04-17 20:51:36 -04:00
|
|
|
|
|
|
|
inherit (self) outputs;
|
2024-02-06 20:35:02 +01:00
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
|
|
|
|
2024-02-01 16:50:14 -05:00
|
|
|
forEachSystem = lib.genAttrs systems;
|
2024-02-02 06:12:49 +01:00
|
|
|
|
2024-05-16 11:39:01 -04:00
|
|
|
# filter out all non-nix files and returns the nix-store path
|
|
|
|
# (ie. git configs, git refs, etc)
|
|
|
|
#
|
|
|
|
# used for module imports and system search
|
2024-04-03 01:20:56 -04:00
|
|
|
src = builtins.filterSource (
|
|
|
|
path: type: type == "directory" || lib.hasSuffix ".nix" (baseNameOf path)
|
|
|
|
) ./.;
|
2024-01-01 12:41:32 -05:00
|
|
|
|
|
|
|
config = {
|
|
|
|
repos = [
|
2024-01-15 13:18:56 -05:00
|
|
|
{
|
2024-04-19 14:09:20 -04:00
|
|
|
repo = "local";
|
2024-03-03 18:06:28 -05:00
|
|
|
hooks = [
|
|
|
|
{
|
2024-04-19 14:09:20 -04:00
|
|
|
id = "nix fmt check";
|
|
|
|
entry = "${outputs.formatter.x86_64-linux}/bin/nixfmt";
|
|
|
|
args = [ "--check" ];
|
|
|
|
language = "system";
|
|
|
|
files = "\\.nix";
|
2024-03-03 18:06:28 -05:00
|
|
|
}
|
|
|
|
];
|
2024-01-15 13:18:56 -05:00
|
|
|
}
|
2024-01-01 12:41:32 -05:00
|
|
|
];
|
|
|
|
};
|
2024-02-02 06:12:49 +01:00
|
|
|
|
2024-05-15 00:38:59 -04:00
|
|
|
# adds our lib functions to lib namespace
|
|
|
|
lib = nixpkgs.lib.extend (
|
2024-05-16 11:39:01 -04:00
|
|
|
self: super:
|
|
|
|
import ./lib {
|
|
|
|
inherit nixpkgs inputs;
|
|
|
|
lib = self;
|
2024-05-15 00:38:59 -04:00
|
|
|
}
|
|
|
|
);
|
2024-05-16 11:39:01 -04:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit (self) outputs;
|
|
|
|
|
|
|
|
hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs; };
|
|
|
|
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
|
2024-05-15 00:38:59 -04:00
|
|
|
|
2023-12-27 10:03:13 +01:00
|
|
|
nixosConfigurations =
|
|
|
|
let
|
2024-03-03 18:06:28 -05:00
|
|
|
constructSystem =
|
|
|
|
{
|
|
|
|
hostname,
|
|
|
|
users,
|
|
|
|
home ? true,
|
|
|
|
iso ? [ ],
|
|
|
|
modules ? [ ],
|
|
|
|
server ? true,
|
|
|
|
sops ? true,
|
|
|
|
system ? "x86_64-linux",
|
|
|
|
}:
|
2024-02-01 16:50:14 -05:00
|
|
|
lib.nixosSystem {
|
2024-02-08 23:50:04 +01:00
|
|
|
system = "x86_64-linux";
|
2024-05-15 04:37:22 -04:00
|
|
|
specialArgs = inputs;
|
2024-03-03 18:06:28 -05:00
|
|
|
modules =
|
|
|
|
[
|
|
|
|
nixos-modules.nixosModule
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
{ config.networking.hostName = "${hostname}"; }
|
2024-05-11 10:16:26 -04:00
|
|
|
./systems/${hostname}/hardware.nix
|
|
|
|
./systems/${hostname}/configuration.nix
|
2024-03-03 18:06:28 -05:00
|
|
|
]
|
2024-05-16 11:39:01 -04:00
|
|
|
++ (lib.rad-dev.fileList src "modules")
|
2024-03-03 18:06:28 -05:00
|
|
|
++ modules
|
|
|
|
++ lib.optional home home-manager.nixosModules.home-manager
|
|
|
|
++ (
|
|
|
|
if home then
|
2024-03-24 14:21:28 -04:00
|
|
|
(map (user: { home-manager.users.${user} = import ./users/${user}/home.nix; }) users)
|
2024-03-03 18:06:28 -05:00
|
|
|
else
|
|
|
|
[ ]
|
|
|
|
)
|
|
|
|
++ lib.optional (system != "x86_64-linux") {
|
|
|
|
config.nixpkgs = {
|
|
|
|
config.allowUnsupportedSystem = true;
|
|
|
|
buildPlatform = "x86_64-linux";
|
2024-02-05 22:45:43 +01:00
|
|
|
};
|
2024-03-03 18:06:28 -05:00
|
|
|
}
|
2024-04-03 01:20:56 -04:00
|
|
|
++ map (
|
|
|
|
user:
|
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}@args:
|
|
|
|
{
|
|
|
|
users.users.${user} = import ./users/${user} (args // { name = "${user}"; });
|
|
|
|
boot.initrd.network.ssh.authorizedKeys =
|
|
|
|
lib.mkIf server
|
|
|
|
config.users.users.${user}.openssh.authorizedKeys.keys;
|
|
|
|
sops = lib.mkIf sops {
|
|
|
|
secrets."${user}/user-password" = {
|
|
|
|
sopsFile = ./users/${user}/secrets.yaml;
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
) users;
|
2023-12-26 19:06:02 +01:00
|
|
|
};
|
2023-12-27 10:03:13 +01:00
|
|
|
in
|
2024-03-03 18:06:28 -05:00
|
|
|
(builtins.listToAttrs (
|
2024-04-03 01:20:56 -04:00
|
|
|
map (system: {
|
|
|
|
name = system;
|
|
|
|
value = constructSystem (
|
|
|
|
{
|
|
|
|
hostname = system;
|
|
|
|
}
|
|
|
|
// builtins.removeAttrs (import ./systems/${system} { inherit inputs; }) [
|
|
|
|
"hostname"
|
|
|
|
"server"
|
|
|
|
"home"
|
|
|
|
]
|
|
|
|
);
|
2024-05-16 11:39:01 -04:00
|
|
|
}) (lib.rad-dev.lsdir src "systems")
|
|
|
|
|
2024-03-03 18:06:28 -05:00
|
|
|
));
|
2024-01-26 23:13:06 +01:00
|
|
|
|
2024-04-03 01:20:56 -04:00
|
|
|
devShell = lib.mapAttrs (
|
|
|
|
system: sopsPkgs:
|
|
|
|
with nixpkgs.legacyPackages.${system};
|
|
|
|
mkShell {
|
|
|
|
sopsPGPKeyDirs = [ "./keys" ];
|
2024-04-20 11:19:29 -04:00
|
|
|
nativeBuildInputs = [ sopsPkgs.sops-import-keys-hook ];
|
2024-04-03 01:20:56 -04:00
|
|
|
packages = [
|
|
|
|
self.formatter.${system}
|
|
|
|
nixpkgs.legacyPackages.${system}.deadnix
|
2024-04-13 17:20:58 -04:00
|
|
|
nixpkgs.legacyPackages.${system}.treefmt
|
|
|
|
nixpkgs.legacyPackages.${system}.pre-commit
|
2024-04-03 01:20:56 -04:00
|
|
|
];
|
|
|
|
shellHook = (nix-pre-commit.lib.${system}.mkConfig { inherit pkgs config; }).shellHook;
|
|
|
|
}
|
|
|
|
) sops-nix.packages;
|
2023-12-27 10:03:13 +01:00
|
|
|
};
|
2023-12-23 06:49:01 +01:00
|
|
|
}
|