moved systemConstants out of flake-parts namespace
also added `systemConstants` as module argument
This commit is contained in:
parent
6f6afcd662
commit
45b63706a4
6 changed files with 76 additions and 83 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
{self, ...}: let
|
|
||||||
imports = [self.modules.generic.systemConstants];
|
|
||||||
in {
|
|
||||||
flake.modules.generic.systemConstants = {config, lib, ...}: {
|
|
||||||
options.systemConstants = lib.mkOption {
|
|
||||||
type = lib.types.lazyAttrsOf lib.types.unspecified;
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
config.systemConstants = {
|
|
||||||
repositoryOwnerUsername = "asnev";
|
|
||||||
repositoryOwnerEmail = "notasnev@proton.me";
|
|
||||||
|
|
||||||
nixpkgsStateVersion = "26.05";
|
|
||||||
nixpkgsAllowUnfree = true;
|
|
||||||
|
|
||||||
homeManagerStateVersion = config.systemConstants.nixpkgsStateVersion;
|
|
||||||
|
|
||||||
primaryUserUsername = "coyote";
|
|
||||||
primaryUserHomeDirectory = "/home/coyote";
|
|
||||||
primaryUserId = 1000;
|
|
||||||
|
|
||||||
phostronHostname = "phostron";
|
|
||||||
phostronHostPlatform = "x86_64-linux";
|
|
||||||
phostronStateVersion = config.systemConstants.nixpkgsStateVersion;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
perSystem = {inherit imports;};
|
|
||||||
flake.modules = {
|
|
||||||
nixos.base = {inherit imports;};
|
|
||||||
homeManager.primaryUser = {inherit imports;};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
{
|
{systemConstants, ...}: {
|
||||||
flake.modules.homeManager.primaryUser = {config, ...}: {
|
flake.modules.homeManager.primaryUser = {
|
||||||
programs.git = {
|
programs.git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
user.name = config.systemConstants.repositoryOwnerUsername;
|
user.name = systemConstants.repositoryOwnerUsername;
|
||||||
user.email = config.systemConstants.repositoryOwnerEmail;
|
user.email = systemConstants.repositoryOwnerEmail;
|
||||||
};
|
};
|
||||||
|
|
||||||
signing = {
|
signing = {
|
||||||
key = "${config.systemConstants.primaryUserHomeDirectory}/.ssh/id_ed25519.pub";
|
key = "${systemConstants.primaryUserHomeDirectory}/.ssh/id_ed25519.pub";
|
||||||
format = "ssh";
|
format = "ssh";
|
||||||
};
|
};
|
||||||
|
|
||||||
includes = [
|
includes = [
|
||||||
{
|
{
|
||||||
condition = "gitdir:${config.systemConstants.primaryUserHomeDirectory}/NixOS/";
|
condition = "gitdir:${systemConstants.primaryUserInfraDirectory}";
|
||||||
contents.core.sshCommand = "ssh -i ${config.systemConstants.primaryUserHomeDirectory}/.ssh/id_ed25519";
|
contents.core.sshCommand = "ssh -i ${systemConstants.primaryUserHomeDirectory}/.ssh/id_ed25519";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,13 @@
|
||||||
{
|
{
|
||||||
self,
|
|
||||||
inputs,
|
inputs,
|
||||||
|
self,
|
||||||
|
systemConstants,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
flake.modules.nixos.phostron = {
|
flake.modules.nixos.phostron = {lib, ...}: {
|
||||||
config,
|
networking.hostName = systemConstants.phostronHostname;
|
||||||
lib,
|
nixpkgs.hostPlatform = lib.mkDefault systemConstants.phostronHostPlatform;
|
||||||
...
|
system.stateVersion = systemConstants.phostronStateVersion;
|
||||||
}: {
|
|
||||||
networking.hostName = config.systemConstants.phostronHostname;
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault config.systemConstants.phostronHostPlatform;
|
|
||||||
system.stateVersion = config.systemConstants.phostronStateVersion;
|
|
||||||
};
|
|
||||||
|
|
||||||
flake.modules.homeManager.primaryUser = {config, ...}: {
|
|
||||||
home.stateVersion = config.systemConstants.phostronStateVersion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.nixosConfigurations.phostron = inputs.nixpkgs.lib.nixosSystem {
|
flake.nixosConfigurations.phostron = inputs.nixpkgs.lib.nixosSystem {
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,27 @@
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
self,
|
systemConstants,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
overlays = [self.overlays.default];
|
overlays = systemConstants.nixpkgsOverlays;
|
||||||
|
config = {allowUnfree = systemConstants.nixpkgsAllowUnfree;};
|
||||||
in {
|
in {
|
||||||
flake-file.inputs = {
|
flake-file.inputs = {
|
||||||
nixpkgs.url = "https://channels.nixos.org/nixos-26.05/nixexprs.tar.zst";
|
nixpkgs.url = "https://channels.nixos.org/nixos-${systemConstants.nixpkgsStableVersion}/nixexprs.tar.zst";
|
||||||
nixpkgs-unstable.url = "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1100280.3ec636362e18/nixexprs.tar.zst";
|
nixpkgs-unstable.url = "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1100280.3ec636362e18/nixexprs.tar.zst";
|
||||||
nixpkgs-lib.follows = "nixpkgs-unstable";
|
nixpkgs-lib.follows = "nixpkgs-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
perSystem = {
|
perSystem = {
|
||||||
config,
|
|
||||||
final,
|
final,
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
_module.args.pkgs = import inputs.nixpkgs {
|
_module.args.pkgs = import inputs.nixpkgs {inherit system overlays config;};
|
||||||
inherit system overlays;
|
overlayAttrs.unstable = import inputs.nixpkgs-unstable {inherit system config;};
|
||||||
config.allowUnfree = config.systemConstants.nixpkgsAllowUnfree;
|
|
||||||
};
|
|
||||||
|
|
||||||
overlayAttrs.unstable = import inputs.nixpkgs-unstable {
|
|
||||||
inherit system;
|
|
||||||
config.allowUnfree = config.systemConstants.nixpkgsAllowUnfree;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.modules.nixos.base = {config, ...}: {
|
flake.modules.nixos.base = {
|
||||||
nixpkgs = {
|
nixpkgs = {inherit overlays config;};
|
||||||
inherit overlays;
|
|
||||||
config.allowUnfree = config.systemConstants.nixpkgsAllowUnfree;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
39
modules/system-constants.nix
Normal file
39
modules/system-constants.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
options.systemConstants = lib.mkOption {
|
||||||
|
type = lib.types.lazyAttrsOf lib.types.unspecified;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.systemConstants = rec {
|
||||||
|
infraName = "chitin";
|
||||||
|
|
||||||
|
repositoryOwnerUsername = "asnev";
|
||||||
|
repositoryOwnerEmail = "notasnev@proton.me";
|
||||||
|
|
||||||
|
nixpkgsStableVersion = "26.05"; # did you read the "did you read the comment?" comment?
|
||||||
|
nixpkgsAllowUnfree = true;
|
||||||
|
nixpkgsOverlays = [self.overlays.default];
|
||||||
|
|
||||||
|
phostronHostname = "phostron";
|
||||||
|
phostronHostPlatform = "x86_64-linux";
|
||||||
|
phostronStateVersion = nixpkgsStableVersion;
|
||||||
|
|
||||||
|
homeManagerStateVersion = nixpkgsStableVersion;
|
||||||
|
|
||||||
|
primaryUserUsername = "coyote";
|
||||||
|
primaryUserHomeDirectory =
|
||||||
|
if pkgs.stdenv.hostPlatform.isLinux
|
||||||
|
then "/home/${primaryUserUsername}"
|
||||||
|
else throw "Unsupported platform: ${pkgs.stdenv.hostPlatform.system}";
|
||||||
|
primaryUserInfraDirectory = "${primaryUserHomeDirectory}/${infraName}";
|
||||||
|
primaryUserId = 1000;
|
||||||
|
};
|
||||||
|
|
||||||
|
config._module.args.systemConstants = config.systemConstants;
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
{self, ...}: {
|
{
|
||||||
flake.modules.nixos.primaryUser = {config, ...}: {
|
self,
|
||||||
users.users.${config.systemConstants.primaryUserUsername} = {
|
systemConstants,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
flake.modules.nixos.primaryUser = {
|
||||||
|
users.users.${systemConstants.primaryUserUsername} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = config.systemConstants.primaryUserUsername;
|
description = systemConstants.primaryUserUsername;
|
||||||
home = config.systemConstants.primaryUserHomeDirectory;
|
home = systemConstants.primaryUserHomeDirectory;
|
||||||
uid = config.systemConstants.primaryUserId;
|
uid = systemConstants.primaryUserId;
|
||||||
extraGroups = [
|
extraGroups = [
|
||||||
"wheel"
|
"wheel"
|
||||||
"networkmanager"
|
"networkmanager"
|
||||||
|
|
@ -19,15 +23,16 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.modules.nixos.homeManagerModule = {config, ...}: {
|
flake.modules.nixos.homeManagerModule = {
|
||||||
home-manager.users.${config.systemConstants.primaryUserUsername} = self.modules.homeManager.primaryUser;
|
home-manager.users.${systemConstants.primaryUserUsername} = self.modules.homeManager.primaryUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.modules.homeManager.primaryUser = {config, ...}: {
|
flake.modules.homeManager.primaryUser = {
|
||||||
home = {
|
home = {
|
||||||
username = config.systemConstants.primaryUserUsername;
|
username = systemConstants.primaryUserUsername;
|
||||||
homeDirectory = config.systemConstants.primaryUserHomeDirectory;
|
homeDirectory = systemConstants.primaryUserHomeDirectory;
|
||||||
shell.enableShellIntegration = true;
|
shell.enableShellIntegration = true;
|
||||||
|
stateVersion = systemConstants.homeManagerStateVersion;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue