initial migration

This commit is contained in:
Chris Kruining 2026-03-24 14:09:46 +00:00
parent 01fb98ba10
commit 59a1fbaf0f
54 changed files with 522 additions and 613 deletions

365
flake.nix
View file

@ -2,13 +2,18 @@
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "clan-core/nixpkgs";
};
clan-core = {
url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
inputs.flake-parts.follows = "flake-parts";
};
nixpkgs.follows = "clan-core/nixpkgs";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@ -20,18 +25,20 @@
inputs.home-manager.follows = "home-manager";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
# Legacy ISO flow removed in favor of Clan install workflows.
# nixos-generators = {
# url = "github:nix-community/nixos-generators";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# neovim
nvf.url = "github:notashelf/nvf";
# plymouth theme
nixos-boot.url = "github:Melkor333/nixos-boot";
# Unused input retained as a comment for easy recovery.
# nixos-boot.url = "github:Melkor333/nixos-boot";
firefox.url = "github:nix-community/flake-firefox-nightly";
# Unused input retained as a comment for easy recovery.
# firefox.url = "github:nix-community/flake-firefox-nightly";
stylix.url = "github:nix-community/stylix";
@ -71,72 +78,312 @@
url = "github:vinceliuice/grub2-themes";
};
nixos-wsl = {
url = "github:nix-community/nixos-wsl";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-compat.follows = "";
};
};
# Unused input retained as a comment for easy recovery.
# nixos-wsl = {
# url = "github:nix-community/nixos-wsl";
# inputs = {
# nixpkgs.follows = "nixpkgs";
# flake-compat.follows = "";
# };
# };
terranix = {
url = "github:terranix/terranix";
inputs.nixpkgs.follows = "nixpkgs";
};
clan-core = {
url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
mydia = {
url = "github:chris-kruining/mydia";
# url = "github:getmydia/mydia";
};
};
outputs = inputs:
inputs.snowfall-lib.mkFlake {
inherit inputs;
src = ./.;
outputs = inputs @ {
flake-parts,
home-manager,
nixpkgs,
...
}: let
inherit (nixpkgs) lib;
snowfall = {
namespace = "sneeuwvlok";
namespace = "sneeuwvlok";
meta = {
name = "sneeuwvlok";
title = "Sneeuwvlok";
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
channelConfig = {
allowUnfree = true;
permittedInsecurePackages = [
# Due to *arr stack
"dotnet-sdk-6.0.428"
"aspnetcore-runtime-6.0.36"
# I think this is because of zen
"qtwebengine-5.15.19"
# For Nheko, the matrix client
"olm-3.2.16"
];
};
packageDefs = {
studio = {
path = ./packages/studio/default.nix;
extra = {
erosanixLib = inputs.erosanix.lib;
};
systems = ["x86_64-linux"];
};
vaultwarden = {
path = ./packages/vaultwarden/default.nix;
extra = {};
systems = supportedSystems;
};
};
mkPackageOverlay = name: def: final: prev:
lib.optionalAttrs (lib.elem final.stdenv.hostPlatform.system def.systems) {
${name} = final.callPackage def.path def.extra;
};
packageOverlays = {
"package/studio" = mkPackageOverlay "studio" packageDefs.studio;
"package/vaultwarden" = mkPackageOverlay "vaultwarden" packageDefs.vaultwarden;
};
systemOverlays = with inputs; [
fenix.overlays.default
nix-minecraft.overlay
flux.overlays.default
];
mkPkgs = system:
import nixpkgs {
inherit system;
overlays = systemOverlays;
config = channelConfig;
};
collectModules = root: let
recurse = prefix: dir: let
entries = builtins.readDir dir;
selfModule =
if builtins.pathExists (dir + "/default.nix")
then {
"${if prefix == "" then "__root" else prefix}" = dir;
}
else {};
in
lib.foldl' (acc: name: let
kind = entries.${name};
path = dir + "/${name}";
rel = if prefix == "" then name else "${prefix}/${name}";
children =
if kind == "directory"
then recurse rel path
else {};
current =
if kind == "directory" && builtins.pathExists (path + "/default.nix")
then {"${rel}" = path;}
else {};
in
acc // children // current) selfModule (builtins.attrNames entries);
in
recurse "" root;
nixosModules = collectModules ./modules/nixos;
homeModules = collectModules ./modules/home;
homeEntries = {
"chris@mandos" = {
machine = "mandos";
user = "chris";
path = ./homes/x86_64-linux + "/chris@mandos";
};
"chris@manwe" = {
machine = "manwe";
user = "chris";
path = ./homes/x86_64-linux + "/chris@manwe";
};
"chris@orome" = {
machine = "orome";
user = "chris";
path = ./homes/x86_64-linux + "/chris@orome";
};
"chris@tulkas" = {
machine = "tulkas";
user = "chris";
path = ./homes/x86_64-linux + "/chris@tulkas";
};
};
sneeuwvlokLib =
(import ./lib/options {inherit lib;})
// (import ./lib/strings {inherit lib;});
machineConfigPaths = builtins.listToAttrs (map (name: lib.nameValuePair name (./machines + "/${name}/configuration.nix")) [
"aule"
"mandos"
"manwe"
"melkor"
"orome"
"tulkas"
"ulmo"
"varda"
"yavanna"
]);
machineHomeModules = lib.mapAttrs' (_: spec: lib.nameValuePair spec.machine [{
users.users.${spec.user} = {
isNormalUser = lib.mkDefault true;
};
home-manager.users.${spec.user} = import spec.path;
}]) homeEntries;
sharedSpecialArgs = {
inherit namespace;
erosanixLib = inputs.erosanix.lib;
repoRoot = ./.;
inherit sneeuwvlokLib;
terranixLib = inputs.terranix.lib;
system = "x86_64-linux";
};
homeSharedModules =
[
inputs.stylix.homeModules.stylix
inputs.plasma-manager.homeModules.plasma-manager
inputs.zen-browser.homeModules.default
]
++ builtins.attrValues homeModules;
baseNixosModules =
[
{ _module.args = sharedSpecialArgs; }
inputs.grub2-themes.nixosModules.default
inputs.home-manager.nixosModules.home-manager
inputs.himmelblau.nixosModules.himmelblau
inputs.jovian.nixosModules.default
inputs.mydia.nixosModules.default
inputs.nix-minecraft.nixosModules.minecraft-servers
inputs.nvf.nixosModules.default
inputs.sops-nix.nixosModules.sops
{
nixpkgs = {
config = channelConfig;
overlays = systemOverlays;
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = sharedSpecialArgs;
sharedModules = homeSharedModules;
};
}
]
++ builtins.attrValues nixosModules;
mkClanMachineModuleList = name:
baseNixosModules
++ (machineHomeModules.${name} or [])
++ [
{
networking.hostName = lib.mkDefault name;
}
];
mkMachineModuleList = name:
mkClanMachineModuleList name
++ [
machineConfigPaths.${name}
];
clanConfig = import ./clan.nix {
inherit sharedSpecialArgs;
mkMachineModuleList = mkClanMachineModuleList;
};
activeMachineNames = builtins.attrNames clanConfig.machines;
nixosConfigurations =
lib.genAttrs activeMachineNames (name:
lib.nixosSystem {
system = "x86_64-linux";
specialArgs = sharedSpecialArgs;
modules = mkMachineModuleList name;
});
homeConfigurations =
lib.mapAttrs (_: spec:
home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs "x86_64-linux";
extraSpecialArgs =
sharedSpecialArgs
// {
osConfig = nixosConfigurations.${spec.machine}.config;
};
modules =
homeSharedModules
++ [
{
home.username = spec.user;
home.homeDirectory = "/home/${spec.user}";
}
spec.path
];
})
homeEntries;
in
flake-parts.lib.mkFlake {inherit inputs;} {
systems = supportedSystems;
imports = [
inputs.clan-core.flakeModules.default
];
clan = clanConfig;
perSystem = {
system,
...
}: let
pkgs = mkPkgs system;
in {
_module.args.pkgs = pkgs;
packages = lib.filterAttrs (_: value: value != null) {
studio =
if lib.elem system packageDefs.studio.systems
then pkgs.callPackage packageDefs.studio.path packageDefs.studio.extra
else null;
vaultwarden =
if lib.elem system packageDefs.vaultwarden.systems
then pkgs.callPackage packageDefs.vaultwarden.path packageDefs.vaultwarden.extra
else null;
};
devShells.default = import ./shells/default/default.nix {
inherit inputs pkgs;
inherit (pkgs) mkShell stdenv;
};
};
channels-config = {
allowUnfree = true;
permittedInsecurePackages = [
# Due to *arr stack
"dotnet-sdk-6.0.428"
"aspnetcore-runtime-6.0.36"
flake = {
inherit homeConfigurations;
nixosConfigurations = lib.mkForce nixosConfigurations;
# I think this is because of zen
"qtwebengine-5.15.19"
lib = sneeuwvlokLib;
# For Nheko, the matrix client
"olm-3.2.16"
];
overlays =
packageOverlays
// {
default = lib.composeManyExtensions (builtins.attrValues packageOverlays);
};
};
overlays = with inputs; [
fenix.overlays.default
nix-minecraft.overlay
flux.overlays.default
];
systems.modules = with inputs; [
clan-core.nixosModules.default
];
homes.modules = with inputs; [
stylix.homeModules.stylix
plasma-manager.homeModules.plasma-manager
];
};
}