mirror of
https://github.com/RGBCube/ncc
synced 2025-07-29 19:17:45 +00:00
Rewrite everythin
This commit is contained in:
parent
a36664a390
commit
7e281a3470
35 changed files with 277 additions and 281 deletions
126
flake.nix
126
flake.nix
|
@ -25,69 +25,87 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, home-manager, fenix, ... }:
|
||||
outputs = { nixpkgs, home-manager, fenix, ... }: let
|
||||
machines = [
|
||||
./machines/asus
|
||||
];
|
||||
|
||||
with {
|
||||
importConfiguration = configDirectory:
|
||||
with {
|
||||
hostName = builtins.baseNameOf configDirectory;
|
||||
hostPlatform = import (configDirectory + "/platform.nix");
|
||||
nixosSystem = arguments: modules: nixpkgs.lib.nixosSystem {
|
||||
specialArgs = arguments;
|
||||
modules = modules;
|
||||
};
|
||||
|
||||
{
|
||||
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = {
|
||||
lib = nixpkgs.lib;
|
||||
importConfiguration = configurationDirectory: let
|
||||
hostName = builtins.baseNameOf configurationDirectory;
|
||||
hostPlatform = import configurationDirectory + "/platform.nix";
|
||||
in {
|
||||
nixosConfigurations.${hostName} = nixosSystem {
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
system = hostPlatform;
|
||||
config.allowUnfree = true;
|
||||
pkgs = import nixpkgs {
|
||||
system = hostPlatform;
|
||||
config.allowUnfree = true;
|
||||
|
||||
overlays = [
|
||||
fenix.overlays.default
|
||||
];
|
||||
};
|
||||
|
||||
# Helper function for DRY.
|
||||
homeManagerConfiguration = userName: attrs: {
|
||||
home-manager.users.${userName} = attrs;
|
||||
};
|
||||
|
||||
# Q: Can't we just do supply a relative path "./foo" ?
|
||||
# A: When configuring our system with flakes, Nix copies them to the
|
||||
# Nix store to run them. So we can't use relative paths as they will refer
|
||||
# to a file which is in the Nix store, and is immutable because it is in
|
||||
# the Nix store, which beats the point of abusing Home Managers
|
||||
# mkOutOfStoreSymlink to create symlinks to mutable files.
|
||||
# To avoid this, we must give an absolute path to a file,
|
||||
# so we do this. The @pwd@ here is replaced by the rebuild script
|
||||
# with the working directory, then changed back after the build.
|
||||
# And yes, this is a major hack.
|
||||
projectPath = "@pwd@";
|
||||
overlays = [
|
||||
fenix.overlays.default
|
||||
];
|
||||
};
|
||||
|
||||
modules = [
|
||||
configDirectory
|
||||
home-manager.nixosModules.home-manager
|
||||
# Helper functions for readability & DRY.
|
||||
systemConfiguration = attributes: attributes;
|
||||
|
||||
{
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
homeConfiguration = userName: attributes: systemConfiguration {
|
||||
home-manager.users.${userName} = attributes;
|
||||
};
|
||||
|
||||
networking.hostName = hostName;
|
||||
nixpkgs.hostPlatform = hostPlatform;
|
||||
imports = importPaths: systemConfiguration {
|
||||
imports = importPaths;
|
||||
};
|
||||
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
packages = packages: systemConfiguration {
|
||||
environment.systemPackages = packages;
|
||||
};
|
||||
|
||||
fonts = fonts: systemConfiguration {
|
||||
fonts.fonts = packages;
|
||||
};
|
||||
|
||||
enabled = attributes: attributes // {
|
||||
enabled = true;
|
||||
};
|
||||
|
||||
normalUser = attributes: attributes // {
|
||||
isNormalUser = true;
|
||||
};
|
||||
|
||||
# Q: Can't we just do supply a relative path "./foo" ?
|
||||
# A: When configuring our system with flakes, Nix copies them to the
|
||||
# Nix store to run them. So we can't use relative paths as they will refer
|
||||
# to a file which is in the Nix store, and is immutable because it is in
|
||||
# the Nix store, which beats the point of abusing Home Managers
|
||||
# mkOutOfStoreSymlink to create symlinks to mutable files.
|
||||
# To avoid this, we must give an absolute path to a file,
|
||||
# so we do this. The @pwd@ here is replaced by the rebuild script
|
||||
# with the working directory, then changed back after the build.
|
||||
# And yes, this is a major hack.
|
||||
projectPath = "@pwd@";
|
||||
} [
|
||||
configurationDirectory
|
||||
home-manager.nixosModules.home-manager
|
||||
|
||||
{
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
|
||||
networking.hostName = hostName;
|
||||
nixpkgs.hostPlatform = hostPlatform;
|
||||
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration [
|
||||
./machines/asus
|
||||
]);
|
||||
in builtins.foldl' nixpkgs.lib.recursiveUpdate {} (builtins.map importConfiguration machines);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue