199 lines
6.2 KiB
Nix
199 lines
6.2 KiB
Nix
{
|
|
description = "NixOS Machine Configurations by manuth";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "nixpkgs/f7207adcc68d9cafa29e3cd252a18743ae512c6a";
|
|
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
|
|
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager?ref=892f76bd0aa09a0f7f73eb41834b8a904b6d0fad";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
sops-nix.url = "github:Mic92/sops-nix?ref=c279dec105dd53df13a5e57525da97905cc0f0d6";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, home-manager, sops-nix }: (
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
|
|
defaultMachine = {
|
|
system = "x86_64-linux";
|
|
modules = [ ];
|
|
|
|
config = { pkgs, ... }: {
|
|
dualBoot = false;
|
|
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;
|
|
};
|
|
nvidia = true;
|
|
users = {
|
|
manuel = {
|
|
fullName = "Manuel Thalmann";
|
|
mail = "m@nuth.ch";
|
|
sudoer = true;
|
|
defaultShell = pkgs.fish;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
machineDefinitions = {
|
|
nixos.config = { ... }: {
|
|
};
|
|
manu-surface.config = { ... }: {
|
|
};
|
|
};
|
|
|
|
machines = builtins.mapAttrs (
|
|
name: machineDefinition:
|
|
defaultMachine // machineDefinition // {
|
|
config = { callPackage, ... }:
|
|
((callPackage defaultMachine.config { }) // (callPackage machineDefinition.config { }));
|
|
})
|
|
machineDefinitions;
|
|
|
|
tryFiles = import ./lib/utils/try-files.nix { inherit lib; };
|
|
in
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
config = {};
|
|
|
|
overlays = [
|
|
sops-nix.overlays.default
|
|
];
|
|
};
|
|
|
|
xonePatcher =
|
|
xone: (xone.overrideAttrs (
|
|
final: prev: {
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "manuth";
|
|
repo = "xone";
|
|
rev = "954fc823fbaa429ad6e1c1a06a4a006598ef35ae";
|
|
sha256 = "lsfm7WDXTB6t05AI/pp17yZvkNvnM2WBMUHL1eVO6qw=";
|
|
};
|
|
}));
|
|
in {
|
|
packages = {
|
|
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
|
|
'';
|
|
xone = xonePatcher pkgs.linuxPackages_latest.xone;
|
|
};
|
|
|
|
devShells.default = pkgs.mkShellNoCC (
|
|
with pkgs;
|
|
{
|
|
sopsPGPKeyDirs = [
|
|
"${toString ./.}/secrets/keys/hosts"
|
|
"${toString ./.}/secrets/keys/users"
|
|
];
|
|
|
|
packages = [
|
|
mkpasswd
|
|
nixos-rebuild
|
|
sops
|
|
sops-import-keys-hook
|
|
ssh-to-age
|
|
ssh-to-pgp
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
sops-import-keys-hook
|
|
];
|
|
});
|
|
}
|
|
) // {
|
|
nixosConfigurations =
|
|
builtins.mapAttrs (
|
|
hostname: { system, config, modules }@machine: nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
|
|
modules = [
|
|
(
|
|
{ pkgs, ... }: {
|
|
config = {
|
|
_module.args = {
|
|
machine = machine // {
|
|
name = hostname;
|
|
config = (pkgs.callPackage config { });
|
|
};
|
|
};
|
|
|
|
home-manager.sharedModules = [
|
|
sops-nix.homeManagerModules.sops
|
|
];
|
|
};
|
|
})
|
|
home-manager.nixosModules.home-manager
|
|
sops-nix.nixosModules.sops
|
|
./lib/configuration.nix
|
|
(tryFiles [ ./lib/machines/${hostname}.nix ] ./lib/hardware/base.nix)
|
|
] ++ modules;
|
|
})
|
|
machines;
|
|
|
|
homeConfigurations =
|
|
let
|
|
lib = nixpkgs.lib;
|
|
in
|
|
lib.attrsets.concatMapAttrs (
|
|
hostname: machine:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit (machine) system;
|
|
};
|
|
|
|
machineConfig = pkgs.callPackage machine.config { };
|
|
in
|
|
lib.attrsets.concatMapAttrs (
|
|
username: user: {
|
|
"${username}@${hostname}" = home-manager.lib.homeManagerConfiguration {
|
|
modules =
|
|
let
|
|
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
|
|
];
|
|
};
|
|
})
|
|
machineConfig.users)
|
|
machines;
|
|
});
|
|
}
|