2023-12-01 11:29:39 +00:00
|
|
|
{
|
2024-05-01 12:00:39 +00:00
|
|
|
description = "NixOS Machine Configurations by manuth";
|
2023-12-01 11:29:39 +00:00
|
|
|
|
2024-05-01 12:00:39 +00:00
|
|
|
inputs = {
|
2024-06-12 01:07:46 +00:00
|
|
|
nixpkgs.url = "nixpkgs/f7207adcc68d9cafa29e3cd252a18743ae512c6a";
|
2024-05-01 16:14:25 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
|
2024-05-09 00:06:59 +00:00
|
|
|
|
|
|
|
home-manager = {
|
2024-06-12 01:07:46 +00:00
|
|
|
url = "github:nix-community/home-manager?ref=892f76bd0aa09a0f7f73eb41834b8a904b6d0fad";
|
2024-05-09 00:06:59 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2024-06-12 01:07:46 +00:00
|
|
|
sops-nix.url = "github:Mic92/sops-nix?ref=c279dec105dd53df13a5e57525da97905cc0f0d6";
|
2024-05-09 09:52:28 +00:00
|
|
|
|
|
|
|
minegrub-theme = {
|
|
|
|
url = "github:Lxtharia/minegrub-theme?ref=08fe7f2b07e0f39426d53e1a1ab5b071e77b9e39";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-05-01 12:00:39 +00:00
|
|
|
};
|
2023-12-01 11:29:39 +00:00
|
|
|
|
2024-05-09 09:52:28 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils, home-manager, sops-nix, minegrub-theme }: (
|
2024-05-08 22:50:42 +00:00
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
2024-05-08 22:59:02 +00:00
|
|
|
|
|
|
|
defaultMachine = {
|
|
|
|
system = "x86_64-linux";
|
2024-06-11 23:35:30 +00:00
|
|
|
modules = [ ];
|
2024-05-08 22:59:02 +00:00
|
|
|
|
|
|
|
config = { pkgs, ... }: {
|
|
|
|
dualBoot = false;
|
2024-05-20 15:24:45 +00:00
|
|
|
timeZone = "Europe/Zurich";
|
|
|
|
keyMap = "de_CH-latin1";
|
|
|
|
keyboardLayout = "ch";
|
|
|
|
localeSettings =
|
|
|
|
let defaultLocale = "en_US.UTF-8";
|
|
|
|
in {
|
|
|
|
LANG = "de_CH.UTF-8";
|
|
|
|
LANGUAGE = defaultLocale;
|
|
|
|
LC_MESSAGE = defaultLocale;
|
|
|
|
};
|
2024-05-07 22:33:39 +00:00
|
|
|
nvidia = true;
|
2024-05-08 07:58:27 +00:00
|
|
|
xone = true;
|
2024-05-20 19:44:15 +00:00
|
|
|
users = {
|
|
|
|
manuel = {
|
|
|
|
fullName = "Manuel Thalmann";
|
|
|
|
mail = "m@nuth.ch";
|
|
|
|
sudoer = true;
|
2024-05-20 20:45:50 +00:00
|
|
|
defaultShell = pkgs.fish;
|
2024-05-20 19:44:15 +00:00
|
|
|
};
|
|
|
|
};
|
2024-05-08 22:59:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-10 23:19:06 +00:00
|
|
|
machineDefinitions = {
|
2024-05-08 22:59:02 +00:00
|
|
|
nixos.config = { ... }: {
|
|
|
|
};
|
2024-05-20 23:57:56 +00:00
|
|
|
manu-surface.config = { ... }: {
|
|
|
|
};
|
2024-05-08 22:59:02 +00:00
|
|
|
};
|
|
|
|
|
2024-05-10 23:22:32 +00:00
|
|
|
machines = builtins.mapAttrs (
|
|
|
|
name: machineDefinition:
|
|
|
|
defaultMachine // machineDefinition // {
|
2024-05-10 23:33:56 +00:00
|
|
|
config = { callPackage, ... }:
|
|
|
|
((callPackage defaultMachine.config { }) // (callPackage machineDefinition.config { }));
|
2024-05-10 23:22:32 +00:00
|
|
|
})
|
|
|
|
machineDefinitions;
|
|
|
|
|
2024-05-08 23:04:55 +00:00
|
|
|
tryFiles = import ./lib/utils/try-files.nix { inherit lib; };
|
2024-05-08 07:58:18 +00:00
|
|
|
|
|
|
|
xonePatcher = { fetchFromGitHub, xone }:
|
|
|
|
xone.overrideAttrs (
|
|
|
|
final: prev: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "manuth";
|
|
|
|
repo = "xone";
|
|
|
|
rev = "954fc823fbaa429ad6e1c1a06a4a006598ef35ae";
|
|
|
|
sha256 = "lsfm7WDXTB6t05AI/pp17yZvkNvnM2WBMUHL1eVO6qw=";
|
|
|
|
};
|
|
|
|
});
|
2024-05-09 11:58:36 +00:00
|
|
|
|
|
|
|
packageDefinitions = {
|
|
|
|
aliae = { buildGoModule, fetchFromGitHub, installShellFiles, ... }:
|
|
|
|
buildGoModule rec {
|
|
|
|
name = "aliae";
|
|
|
|
version = "0.21.0";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "JanDeDobbeleer";
|
|
|
|
repo = name;
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "Xg3fJs10euju26iJky5UGGGKov47Q16IZQP28ubNca0=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
|
|
|
sourceRoot = "${src.name}/src";
|
|
|
|
vendorHash = "sha256-sXZ6Rdqy6VtYlQ3UoNWpgdri61b6aX+uAzLVa/y1lbU=";
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{src,aliae}
|
|
|
|
installShellCompletion --cmd aliae \
|
|
|
|
--bash <($out/bin/aliae completion bash) \
|
|
|
|
--fish <($out/bin/aliae completion fish) \
|
|
|
|
--zsh <($out/bin/aliae completion zsh)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
xone = pkgs: xonePatcher {
|
|
|
|
inherit (pkgs) fetchFromGitHub;
|
|
|
|
inherit (pkgs.linuxPackages_latest) xone;
|
|
|
|
};
|
|
|
|
};
|
2024-05-08 22:50:42 +00:00
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
2024-05-10 23:28:15 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config = {};
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
overlays = [
|
|
|
|
sops-nix.overlays.default
|
2024-05-08 22:50:42 +00:00
|
|
|
];
|
2024-05-10 23:28:15 +00:00
|
|
|
};
|
|
|
|
in {
|
2024-05-09 11:58:36 +00:00
|
|
|
packages = (builtins.mapAttrs (name: packageDefinition: pkgs.callPackage packageDefinition { }) packageDefinitions) // {
|
2024-05-16 00:25:41 +00:00
|
|
|
rcloneDocs =
|
|
|
|
let
|
|
|
|
module = lib.evalModules {
|
|
|
|
modules = [
|
|
|
|
({ pkgs, ... }@args: {
|
|
|
|
inherit (import ./lib/modules/rclone.nix args) options;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
optionsDoc = pkgs.nixosOptionsDoc {
|
|
|
|
options = module.options;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
pkgs.runCommand "options-doc.md" {} ''
|
|
|
|
cat ${optionsDoc.optionsCommonMark} >> $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
devShells.default = pkgs.mkShellNoCC (
|
|
|
|
with pkgs;
|
|
|
|
{
|
|
|
|
sopsPGPKeyDirs = [
|
2024-05-03 12:07:10 +00:00
|
|
|
"${toString ./.}/secrets/keys/hosts"
|
|
|
|
"${toString ./.}/secrets/keys/users"
|
2024-05-10 23:28:15 +00:00
|
|
|
];
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
packages = [
|
2024-05-03 12:03:42 +00:00
|
|
|
mkpasswd
|
2024-05-10 23:28:15 +00:00
|
|
|
nixos-rebuild
|
|
|
|
sops
|
|
|
|
sops-import-keys-hook
|
|
|
|
ssh-to-age
|
|
|
|
ssh-to-pgp
|
|
|
|
];
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
sops-import-keys-hook
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2024-05-08 22:50:42 +00:00
|
|
|
) // {
|
2024-05-09 08:17:52 +00:00
|
|
|
overlays.default =
|
2024-05-09 11:58:36 +00:00
|
|
|
final: prev: (
|
|
|
|
{
|
|
|
|
linuxPackages_latest.xone = packageDefinitions.xone final;
|
|
|
|
} //
|
|
|
|
(lib.attrsets.concatMapAttrs (
|
|
|
|
name: package:
|
|
|
|
if name == "xone"
|
|
|
|
then {}
|
|
|
|
else {
|
|
|
|
${name} = package final;
|
|
|
|
})
|
|
|
|
packageDefinitions));
|
2024-05-09 08:17:52 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
nixosConfigurations =
|
|
|
|
builtins.mapAttrs (
|
2024-06-11 23:35:30 +00:00
|
|
|
hostname: { system, config, modules }@machine: nixpkgs.lib.nixosSystem {
|
2024-05-08 22:50:42 +00:00
|
|
|
inherit system;
|
2024-05-01 16:58:39 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
modules = [
|
|
|
|
(
|
2024-05-10 23:33:56 +00:00
|
|
|
{ pkgs, ... }: {
|
2024-05-11 18:28:41 +00:00
|
|
|
config = {
|
|
|
|
_module.args = {
|
|
|
|
machine = machine // {
|
|
|
|
name = hostname;
|
|
|
|
config = (pkgs.callPackage config { });
|
|
|
|
};
|
2024-05-11 17:40:01 +00:00
|
|
|
};
|
2024-05-11 18:28:41 +00:00
|
|
|
|
2024-05-09 08:17:52 +00:00
|
|
|
nixpkgs.overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
];
|
|
|
|
|
2024-05-11 18:28:41 +00:00
|
|
|
home-manager.sharedModules = [
|
|
|
|
sops-nix.homeManagerModules.sops
|
|
|
|
];
|
2024-05-08 22:50:42 +00:00
|
|
|
};
|
|
|
|
})
|
2024-05-09 00:06:59 +00:00
|
|
|
home-manager.nixosModules.home-manager
|
2024-05-09 09:52:28 +00:00
|
|
|
minegrub-theme.nixosModules.default
|
2024-05-08 22:50:42 +00:00
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
./lib/configuration.nix
|
2024-05-10 23:19:06 +00:00
|
|
|
(tryFiles [ ./lib/machines/${hostname}.nix ] ./lib/hardware/base.nix)
|
2024-06-11 23:35:30 +00:00
|
|
|
] ++ modules;
|
2024-05-08 22:59:02 +00:00
|
|
|
})
|
2024-05-10 23:19:06 +00:00
|
|
|
machines;
|
2024-05-08 22:59:02 +00:00
|
|
|
|
|
|
|
homeConfigurations =
|
|
|
|
let
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
in
|
|
|
|
lib.attrsets.concatMapAttrs (
|
2024-05-10 23:19:06 +00:00
|
|
|
hostname: machine:
|
2024-05-08 22:59:02 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit (machine) system;
|
|
|
|
};
|
2024-05-10 23:33:56 +00:00
|
|
|
|
|
|
|
machineConfig = pkgs.callPackage machine.config { };
|
2024-05-08 22:59:02 +00:00
|
|
|
in
|
|
|
|
lib.attrsets.concatMapAttrs (
|
|
|
|
username: user: {
|
2024-05-09 00:06:59 +00:00
|
|
|
"${username}@${hostname}" = home-manager.lib.homeManagerConfiguration {
|
2024-05-08 22:59:02 +00:00
|
|
|
modules =
|
|
|
|
let
|
2024-05-11 19:35:13 +00:00
|
|
|
getUserModule = pkgs.callPackage (import ./lib/utils/user-module.nix);
|
|
|
|
in
|
|
|
|
getUserModule {
|
|
|
|
machine = machine // {
|
|
|
|
name = hostname;
|
|
|
|
config = machineConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
user = {
|
|
|
|
name = username;
|
|
|
|
} // user;
|
|
|
|
} ++ [
|
|
|
|
sops-nix.homeManagerModules.sops
|
|
|
|
];
|
2024-05-08 22:59:02 +00:00
|
|
|
};
|
|
|
|
})
|
2024-05-10 23:33:56 +00:00
|
|
|
machineConfig.users)
|
2024-05-08 22:59:02 +00:00
|
|
|
machines;
|
|
|
|
});
|
2023-12-01 11:29:39 +00:00
|
|
|
}
|