refactor: get rid of vars and move common to modules
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-22 23:15:13 -05:00
parent e8fff0bbd3
commit c43560ff95
35 changed files with 407 additions and 423 deletions

View file

@ -1,147 +0,0 @@
{
config,
home-manager,
lib,
nh,
nixd,
pkgs,
self,
...
}: let
inherit (lib) attrValues filter findFirst isAttrs hasAttr mkIf mkOption types;
in {
imports = [
./vars
./modules
./packages.nix
self.nixosModules.borgbackup
self.nixosModules.tmux
{programs.tmux.enableCustomConf = true;}
home-manager.nixosModules.home-manager
];
boot.tmp.useTmpfs = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/home/nix-cache";
preStart = ''
mkdir -p ${config.systemd.services.nix-daemon.environment.TMPDIR}
'';
};
nix = {
package = let
nixdInput =
findFirst
(x: x.pname == "nix") {}
nixd.packages.${pkgs.system}.nixd.buildInputs;
throws = x: !(builtins.tryEval x).success;
hasVersion = x: isAttrs x && hasAttr "version" x;
nixVersions = filter (x: ! throws x && hasVersion x) (attrValues pkgs.nixVersions);
in
findFirst (x: x.version == nixdInput.version) {} nixVersions;
# Edit nix.conf
settings = {
# Store
keep-outputs = true;
keep-derivations = true;
auto-optimise-store = true;
# Commands
experimental-features = ["nix-command" "flakes"];
http-connections = 0; # unlimited for local cache
warn-dirty = false;
show-trace = true;
allow-import-from-derivation = true;
# remote building
trusted-users = ["matt" "nixremote"];
};
};
programs.nh = {
enable = true;
package = nh.packages.${pkgs.system}.default;
# weekly cleanup
clean = {
enable = true;
extraArgs = "--keep-since 30d";
};
};
services = {
fwupd.enable = true;
xserver.xkb = {
layout = "ca";
variant = "multix";
};
};
boot.supportedFilesystems = ["ext4" "xfs" "btrfs" "vfat" "ntfs"];
system.fsPackages = builtins.attrValues {
inherit
(pkgs)
btrfs-progs
nfs-utils
ntfs3g
xfsprogs
;
};
environment.variables.NPM_CONFIG_GLOBALCONFIG = "/etc/npmrc";
environment.etc.npmrc.text = ''
fund = false
update-notifier = false
'';
environment.systemPackages = builtins.attrValues {
# Peripherals
inherit
(pkgs)
hdparm
pciutils
usbutils
rar
;
};
home-manager.users = let
inherit (config.vars) mainUser;
default = {
imports = [
# Make the vars be the same on Nix and HM
{
options.vars = mkOption {
type = types.attrs;
readOnly = true;
default = config.vars;
};
}
{
programs.bash = {
sessionVariables = rec {
FLAKE = config.environment.variables.FLAKE;
NH_FLAKE = FLAKE;
};
shellAliases.nh = "env -u FLAKE nh";
};
}
];
home.stateVersion = config.system.stateVersion;
};
in {
greeter = mkIf (config.services.greetd.enable) default;
${mainUser} = default;
};
}

View file

@ -1,8 +0,0 @@
{...}: {
imports = [
./cachix.nix
./locale.nix
./locate.nix
./global.nix
];
}

View file

@ -1,23 +0,0 @@
{
config,
lib,
nixpkgs,
...
}: let
inherit (config.sops.secrets) access-token;
inherit (lib) hasAttr optionalString;
in {
# Minimize dowloads of indirect nixpkgs flakes
nix = {
registry.nixpkgs.flake = nixpkgs;
nixPath = ["nixpkgs=${nixpkgs}"];
extraOptions =
optionalString (hasAttr "sops" config)
"!include ${access-token.path}";
};
# Global hm settings
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}

View file

@ -1,116 +0,0 @@
inputs @ {
pkgs,
self,
...
}: {
nixpkgs.overlays =
(map (i: inputs.${i}.overlays.default) [
"discord-overlay"
"grim-hyprland"
"nixpkgs-wayland"
])
++ (builtins.attrValues {
inherit
(self.overlays)
xdg-desktop-portal-kde
;
});
environment.systemPackages =
(builtins.attrValues {
inherit
(self.packages.${pkgs.system})
pokemon-colorscripts
repl
;
inherit
(pkgs.nodePackages)
undollar
;
inherit (pkgs) alejandra;
# Archiving
inherit
(pkgs)
zip
unzip
p7zip
bzip2
gzip
gnutar
xz
;
# File management
inherit
(pkgs)
findutils
diffutils
util-linux
which
imagemagick
;
# Networking
inherit (pkgs.dig) dnsutils;
inherit
(pkgs)
arp-scan
openssh
rsync
wget
gnupg
;
# Misc CLI stuff
inherit
(pkgs)
hydra-check
killall
nix-output-monitor
nix-melt
progress
tree
gnugrep
gnused
;
# Expected Stuff
inherit
(pkgs)
hostname
man
perl
tzdata
;
})
++ [
# This could help as well: nix derivation show -r /run/current-system
(pkgs.writeShellApplication {
name = "listDerivs";
text = ''
exec nix-store --query --requisites /run/current-system | cut -d- -f2- | sort -u
'';
})
(pkgs.writeShellApplication {
name = "from";
runtimeInputs = builtins.attrValues {
inherit
(pkgs)
coreutils
which
;
};
text = ''
for var do
realpath "$(which "$var")"
done
'';
})
];
}

View file

@ -1,21 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib) mkDefault mkOption types;
cfg = config.vars;
in {
options.vars = {
mainUser = mkOption {
type = types.str;
description = ''
Username that was defined at the initial setup process
'';
};
};
config = {
environment.variables.FLAKE = mkDefault "/home/${cfg.mainUser}/.nix";
};
}

View file

@ -14,26 +14,3 @@ This directory encompasses every device's main configuration file.
| `nos` | My custom built NAS | | `nos` | My custom built NAS |
| `servivi` | A gaming PC in a previous life, it is now used as a build farm and hosts game servers | | `servivi` | A gaming PC in a previous life, it is now used as a build farm and hosts game servers |
| `wim` | My 2-1 Lenovo Laptop that I use for uni | | `wim` | My 2-1 Lenovo Laptop that I use for uni |
## Global Vars
In every device's `default.nix`, you'll find these [settings](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/common/vars/default.nix)
```nix
# $FLAKE/devices/<name>/default.nix
vars = {
mainUser = "matt";
...
};
```
from these declared settings, I get access to global variables
that are different on each host using a 'let in' block:
```nix
let
inherit (config.vars) mainUser ...;
in {
...
```

View file

@ -1,6 +1,6 @@
# FIXME: eval is broken
{ {
config, config,
lib,
self, self,
... ...
}: { }: {
@ -35,15 +35,6 @@
# Global hm settings # Global hm settings
home-manager.config = { home-manager.config = {
imports = [ imports = [
# Make the vars be the same on Nix and HM
{
options.vars = lib.mkOption {
type = lib.types.attrs;
readOnly = true;
default = config.vars;
};
}
self.homeManagerModules.neovim self.homeManagerModules.neovim
{programs.neovim.enable = true;} {programs.neovim.enable = true;}

View file

@ -1,10 +1,8 @@
{ {
config, mainUser,
self, self,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -13,6 +11,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.plymouth self.nixosModules.plymouth
self.nixosModules.server self.nixosModules.server
@ -24,8 +23,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "mariah";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -44,6 +41,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.server = { roles.server = {
user = mainUser; user = mainUser;
sshd.enable = true; sshd.enable = true;

View file

@ -1,14 +1,13 @@
defaultSession: { defaultSession: {
config, config,
lib, lib,
mainUser,
pkgs, pkgs,
... ...
}: { }: {
config = let config = let
inherit (lib) findFirst getExe mkForce; inherit (lib) findFirst getExe mkForce;
inherit (config.vars) mainUser;
switch-session = pkgs.writeShellApplication { switch-session = pkgs.writeShellApplication {
name = "switch-session"; name = "switch-session";

View file

@ -1,13 +1,12 @@
defaultSession: { defaultSession: {
config, config,
lib, lib,
mainUser,
pkgs, pkgs,
self, self,
... ...
}: { }: {
config = let config = {
inherit (config.vars) mainUser;
in {
# Normal Steam Stuff # Normal Steam Stuff
programs.steam = { programs.steam = {
enable = true; enable = true;

View file

@ -1,10 +1,8 @@
{ {
config, mainUser,
self, self,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -13,6 +11,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.desktop self.nixosModules.desktop
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
@ -24,8 +23,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -52,6 +49,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.desktop = { roles.desktop = {
user = mainUser; user = mainUser;

View file

@ -1,12 +1,12 @@
{ {
config, config,
lib, lib,
mainUser,
pkgs, pkgs,
self, self,
... ...
}: let }: let
inherit (lib) concatStringsSep getExe removePrefix; inherit (lib) concatStringsSep getExe removePrefix;
inherit (config.vars) mainUser;
inherit (self.packages.${pkgs.system}) gpu-screen-recorder gsr-kms-server; inherit (self.packages.${pkgs.system}) gpu-screen-recorder gsr-kms-server;
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage; hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;

View file

@ -1,10 +1,9 @@
deviceName: { deviceName: {
config, config,
mainUser,
self, self,
... ...
}: let }: let
inherit (config.vars) mainUser;
clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip; clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip;
in { in {
# ------------------------------------------------ # ------------------------------------------------
@ -15,6 +14,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
]; ];
@ -25,8 +25,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -54,6 +52,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.server = { roles.server = {
user = mainUser; user = mainUser;
tailscale.enable = true; tailscale.enable = true;

View file

@ -1,11 +1,11 @@
{ {
caddy-plugins, caddy-plugins,
pkgs,
config, config,
mainUser,
pkgs,
... ...
}: let }: let
inherit (config.sops) secrets; inherit (config.sops) secrets;
inherit (config.vars) mainUser;
inherit (config.networking) hostName; inherit (config.networking) hostName;
caddy = caddy-plugins.packages.${pkgs.system}.default; caddy = caddy-plugins.packages.${pkgs.system}.default;

View file

@ -1,5 +1,8 @@
{config, ...}: let {
inherit (config.vars) mainUser; config,
mainUser,
...
}: let
inherit (config.networking) hostName; inherit (config.networking) hostName;
clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip; clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip;

View file

@ -1,6 +1,7 @@
{ {
config, config,
lib, lib,
mainUser,
... ...
}: let }: let
inherit (lib) foldl isList mapAttrsToList mergeAttrsWithFunc remove unique; inherit (lib) foldl isList mapAttrsToList mergeAttrsWithFunc remove unique;
@ -11,7 +12,6 @@
else b)) {} else b)) {}
list; list;
inherit (config.vars) mainUser;
inherit (config.networking) hostName; inherit (config.networking) hostName;
serviviIP = "100.64.0.7"; serviviIP = "100.64.0.7";

View file

@ -1,10 +1,8 @@
{ {
config, mainUser,
self, self,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -13,6 +11,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.docker self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
@ -24,8 +23,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -45,6 +42,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.server = { roles.server = {
user = mainUser; user = mainUser;
tailscale.enable = true; tailscale.enable = true;

View file

@ -1,10 +1,9 @@
{ {
config, config,
mainUser,
pkgs, pkgs,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
hardware.bluetooth = { hardware.bluetooth = {
enable = true; enable = true;
powerOnBoot = true; powerOnBoot = true;

View file

@ -1,10 +1,8 @@
{ {
config, mainUser,
self, self,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -13,6 +11,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.docker self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
@ -24,8 +23,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -46,6 +43,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.server = { roles.server = {
user = mainUser; user = mainUser;
tailscale.enable = true; tailscale.enable = true;

View file

@ -1,11 +1,11 @@
{ {
config, config,
jellyfin-flake, jellyfin-flake,
mainUser,
lib, lib,
... ...
}: let }: let
inherit (lib) hasAttr optionals; inherit (lib) hasAttr optionals;
inherit (config.vars) mainUser;
optionalGroup = name: optionalGroup = name:
optionals optionals

View file

@ -1,10 +1,9 @@
{ {
config, config,
mainUser,
pkgs, pkgs,
... ...
} @ inputs: let } @ inputs: let
inherit (config.vars) mainUser;
convertMkv = pkgs.callPackage ./convert.nix {inherit pkgs;}; convertMkv = pkgs.callPackage ./convert.nix {inherit pkgs;};
extractSubs = pkgs.callPackage ./extract-subs {inherit pkgs;}; extractSubs = pkgs.callPackage ./extract-subs {inherit pkgs;};
sub-clean = pkgs.callPackage ./cleanup.nix {inherit pkgs;}; sub-clean = pkgs.callPackage ./cleanup.nix {inherit pkgs;};

View file

@ -1,10 +1,8 @@
{ {
config, mainUser,
self, self,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -13,6 +11,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.docker self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
@ -24,8 +23,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users = { users.users = {
${mainUser} = { ${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -59,6 +56,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.server = { roles.server = {
user = mainUser; user = mainUser;
tailscale.enable = true; tailscale.enable = true;

View file

@ -1,10 +1,10 @@
{ {
config, config,
mainUser,
nix-fast-build, nix-fast-build,
pkgs, pkgs,
... ...
}: let }: let
inherit (config.vars) mainUser;
inherit (config.sops) secrets; inherit (config.sops) secrets;
nix-fast-build-pkg = nix-fast-build.packages.${pkgs.system}.nix-fast-build.override { nix-fast-build-pkg = nix-fast-build.packages.${pkgs.system}.nix-fast-build.override {

View file

@ -1,11 +1,9 @@
{ {
config, mainUser,
minix, minix,
pkgs, pkgs,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
imports = [minix.nixosModules.default]; imports = [minix.nixosModules.default];
environment.systemPackages = [ environment.systemPackages = [

View file

@ -1,11 +1,9 @@
{ {
config, mainUser,
self, self,
pkgs, pkgs,
... ...
}: let }: {
inherit (config.vars) mainUser;
in {
# ------------------------------------------------ # ------------------------------------------------
# Imports # Imports
# ------------------------------------------------ # ------------------------------------------------
@ -14,6 +12,7 @@ in {
./modules ./modules
self.nixosModules.base
self.nixosModules.desktop self.nixosModules.desktop
self.nixosModules.docker self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
@ -27,8 +26,6 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars.mainUser = "matt";
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
@ -62,6 +59,11 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# `Self` Modules configuration # `Self` Modules configuration
# ------------------------------------------------ # ------------------------------------------------
roles.base = {
enable = true;
user = mainUser;
};
roles.desktop = { roles.desktop = {
user = mainUser; user = mainUser;

Binary file not shown.

View file

@ -32,15 +32,16 @@ inputs: rec {
mkNixOS = { mkNixOS = {
extraModules ? [], extraModules ? [],
cudaSupport ? false, cudaSupport ? false,
mainUser ? "matt",
}: }:
inputs.nixpkgs.lib.nixosSystem rec { inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = inputs; specialArgs = inputs // {inherit mainUser;};
modules = modules =
[ [
(allowModularOverrides {inherit system cudaSupport;}) (allowModularOverrides {inherit system cudaSupport;})
inputs.home-manager.nixosModules.home-manager
{home-manager.extraSpecialArgs = specialArgs;} {home-manager.extraSpecialArgs = specialArgs;}
../../common
] ]
++ extraModules; ++ extraModules;
}; };

View file

@ -0,0 +1,31 @@
self: {
config,
lib,
...
}: let
inherit (lib) hasAttr mkIf optionalString;
inherit (self.inputs) nixpkgs;
inherit (config.sops.secrets) access-token;
cfg = config.roles.base;
in {
config = mkIf cfg.enable {
# Minimize dowloads of indirect nixpkgs flakes
nix = {
registry.nixpkgs.flake = nixpkgs;
nixPath = ["nixpkgs=${nixpkgs}"];
extraOptions =
optionalString (hasAttr "sops" config)
"!include ${access-token.path}";
};
# Global hm settings
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -0,0 +1,155 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) attrValues filter findFirst isAttrs hasAttr mkDefault mkIf mkOption types;
inherit (self.inputs) home-manager nh nixd;
cfg = config.roles.base;
in {
imports = [
./locale
./locate
./substituters
(import ./common-nix self)
(import ./packages self)
self.nixosModules.borgbackup
self.nixosModules.tmux
home-manager.nixosModules.home-manager
];
options.roles.base = {
enable = mkOption {
type = types.bool;
default = true;
};
user = mkOption {
type = types.str;
};
};
config = mkIf (cfg.enable) {
environment.variables.FLAKE = mkDefault "/home/${cfg.user}/.nix";
programs.tmux.enableCustomConf = true;
boot.tmp.useTmpfs = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/home/nix-cache";
preStart = ''
mkdir -p ${config.systemd.services.nix-daemon.environment.TMPDIR}
'';
};
nix = {
package = let
nixdInput =
findFirst
(x: x.pname == "nix") {}
nixd.packages.${pkgs.system}.nixd.buildInputs;
throws = x: !(builtins.tryEval x).success;
hasVersion = x: isAttrs x && hasAttr "version" x;
nixVersions = filter (x: ! throws x && hasVersion x) (attrValues pkgs.nixVersions);
in
findFirst (x: x.version == nixdInput.version) {} nixVersions;
# Edit nix.conf
settings = {
# Store
keep-outputs = true;
keep-derivations = true;
auto-optimise-store = true;
# Commands
experimental-features = ["nix-command" "flakes"];
http-connections = 0; # unlimited for local cache
warn-dirty = false;
show-trace = true;
allow-import-from-derivation = true;
# remote building
trusted-users = ["matt" "nixremote"];
};
};
programs.nh = {
enable = true;
package = nh.packages.${pkgs.system}.default;
# weekly cleanup
clean = {
enable = true;
extraArgs = "--keep-since 30d";
};
};
services = {
fwupd.enable = true;
xserver.xkb = {
layout = "ca";
variant = "multix";
};
};
boot.supportedFilesystems = ["ext4" "xfs" "btrfs" "vfat" "ntfs"];
system.fsPackages = attrValues {
inherit
(pkgs)
btrfs-progs
nfs-utils
ntfs3g
xfsprogs
;
};
environment.variables.NPM_CONFIG_GLOBALCONFIG = "/etc/npmrc";
environment.etc.npmrc.text = ''
fund = false
update-notifier = false
'';
environment.systemPackages = attrValues {
# Peripherals
inherit
(pkgs)
hdparm
pciutils
usbutils
rar
;
};
home-manager.users = let
default = {
imports = [
{
programs.bash = {
sessionVariables = rec {
FLAKE = config.environment.variables.FLAKE;
NH_FLAKE = FLAKE;
};
shellAliases.nh = "env -u FLAKE nh";
};
}
];
home.stateVersion = config.system.stateVersion;
};
in {
greeter = mkIf (config.services.greetd.enable) default;
${cfg.user} = default;
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -4,25 +4,27 @@
lib, lib,
... ...
}: let }: let
inherit (config.vars) mainUser; inherit (lib) concatStringsSep getName;
baseCfg = config.roles.base;
cfg = config.services.locate; cfg = config.services.locate;
locateGroup = lib.getName cfg.package.name; locateGroup = getName cfg.package.name;
locate = "${cfg.package}/bin/locate"; locate = "${cfg.package}/bin/locate";
updatedb = "${cfg.package}/bin/updatedb"; updatedb = "${cfg.package}/bin/updatedb";
database = "/var/lib/locate/locatedb"; database = "/var/lib/locate/locatedb";
pruneFS = builtins.concatStringsSep " " cfg.pruneFS; pruneFS = concatStringsSep " " cfg.pruneFS;
pruneNames = builtins.concatStringsSep " " cfg.pruneNames; pruneNames = concatStringsSep " " cfg.pruneNames;
prunePaths = builtins.concatStringsSep " " cfg.prunePaths; prunePaths = concatStringsSep " " cfg.prunePaths;
updatedbBin = '' updatedbBin = ''
${updatedb} -o ${database} --prunefs "${pruneFS}" \ ${updatedb} -o ${database} --prunefs "${pruneFS}" \
--prunepaths "${prunePaths}" --prunenames "${pruneNames}" --prunepaths "${prunePaths}" --prunenames "${pruneNames}"
''; '';
in { in {
users.users.${mainUser}.extraGroups = [ users.users.${baseCfg.user}.extraGroups = [
locateGroup locateGroup
]; ];
@ -30,7 +32,7 @@ in {
systemd.services.locate = { systemd.services.locate = {
wantedBy = ["default.target"]; wantedBy = ["default.target"];
serviceConfig = { serviceConfig = {
User = mainUser; User = baseCfg.user;
Group = locateGroup; Group = locateGroup;
StateDirectory = "locate"; StateDirectory = "locate";
StateDirectoryMode = "0770"; StateDirectoryMode = "0770";
@ -38,7 +40,7 @@ in {
}; };
}; };
home-manager.users.${mainUser}.programs.bash.shellAliases = { home-manager.users.${baseCfg.user}.programs.bash.shellAliases = {
locate = "${pkgs.writeShellScriptBin "lct" '' locate = "${pkgs.writeShellScriptBin "lct" ''
exec ${locate} -d ${database} "$@" 2> >(grep -v "/var/cache/locatedb") exec ${locate} -d ${database} "$@" 2> >(grep -v "/var/cache/locatedb")
''}/bin/lct"; ''}/bin/lct";

View file

@ -0,0 +1,126 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) attrValues mkIf;
cfg = config.roles.base;
in {
config = mkIf (cfg.enable) {
nixpkgs.overlays =
(map (i: self.inputs.${i}.overlays.default) [
"discord-overlay"
"grim-hyprland"
"nixpkgs-wayland"
])
++ (attrValues {
inherit
(self.overlays)
xdg-desktop-portal-kde
;
});
environment.systemPackages =
(attrValues {
inherit
(self.packages.${pkgs.system})
pokemon-colorscripts
repl
;
inherit
(pkgs.nodePackages)
undollar
;
inherit (pkgs) alejandra;
# Archiving
inherit
(pkgs)
zip
unzip
p7zip
bzip2
gzip
gnutar
xz
;
# File management
inherit
(pkgs)
findutils
diffutils
util-linux
which
imagemagick
;
# Networking
inherit (pkgs.dig) dnsutils;
inherit
(pkgs)
arp-scan
openssh
rsync
wget
gnupg
;
# Misc CLI stuff
inherit
(pkgs)
hydra-check
killall
nix-output-monitor
nix-melt
progress
tree
gnugrep
gnused
;
# Expected Stuff
inherit
(pkgs)
hostname
man
perl
tzdata
;
})
++ [
# This could help as well: nix derivation show -r /run/current-system
(pkgs.writeShellApplication {
name = "listDerivs";
text = ''
exec nix-store --query --requisites /run/current-system | cut -d- -f2- | sort -u
'';
})
(pkgs.writeShellApplication {
name = "from";
runtimeInputs = attrValues {
inherit
(pkgs)
coreutils
which
;
};
text = ''
for var do
realpath "$(which "$var")"
done
'';
})
];
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -18,7 +18,7 @@ in {
name = "rebuild-no-cache"; name = "rebuild-no-cache";
runtimeInputs = [config.programs.nh.package]; runtimeInputs = [config.programs.nh.package];
text = '' text = ''
nh os switch -- --option binary-caches "https://cache.nixos.org" "$@" exec nh os switch -- --option binary-caches "https://cache.nixos.org" "$@"
''; '';
}) })
]; ];

View file

@ -1,4 +1,5 @@
self: { self: {
base = import ./base self;
borgbackup = import ./borgbackup; borgbackup = import ./borgbackup;
desktop = import ./desktop self; desktop = import ./desktop self;
docker = import ./docker self.inputs.khepri; docker = import ./docker self.inputs.khepri;

View file

@ -73,7 +73,10 @@
extraModules = [./devices/binto]; extraModules = [./devices/binto];
}; };
bbsteamie = mkNixOS {extraModules = [./devices/bbsteamie];}; bbsteamie = mkNixOS {
mainUser = "mariah";
extraModules = [./devices/bbsteamie];
};
# NAS # NAS
nos = mkNixOS { nos = mkNixOS {
@ -117,7 +120,7 @@
live-image = mkNixOS { live-image = mkNixOS {
extraModules = [ extraModules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
{vars.mainUser = "nixos";} # {vars.mainUser = "nixos";} FIXME: add default modules and stuff
]; ];
}; };
}; };