parent
1ce40f2c1a
commit
6ca0d7248b
329 changed files with 178 additions and 139 deletions
modules/base
46
modules/base/common-nix/default.nix
Normal file
46
modules/base/common-nix/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) attrValues filter findFirst hasAttr isAttrs mkIf optionalString;
|
||||
|
||||
inherit (self.inputs) nixd nixpkgs;
|
||||
inherit (config.sops.secrets) access-token;
|
||||
|
||||
cfg = config.roles.base;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
nix = {
|
||||
# FIXME: infinite recursion if not set
|
||||
package = let
|
||||
nixdInput =
|
||||
findFirst
|
||||
(x: x.pname == "nix") {}
|
||||
nixd.packages.x86_64-linux.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;
|
||||
|
||||
# Minimize dowloads of indirect nixpkgs flakes
|
||||
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;
|
||||
}
|
22
modules/base/default-droid.nix
Normal file
22
modules/base/default-droid.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
self: {lib, ...}: let
|
||||
inherit (lib) mkOption types;
|
||||
in {
|
||||
imports = [
|
||||
(import ./common-nix self)
|
||||
(import ./packages self)
|
||||
];
|
||||
|
||||
options.roles.base = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./default.nix;
|
||||
}
|
143
modules/base/default.nix
Normal file
143
modules/base/default.nix
Normal file
|
@ -0,0 +1,143 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) attrValues mkDefault mkIf mkOption types;
|
||||
inherit (self.inputs) home-manager nh;
|
||||
|
||||
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 = {
|
||||
# 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;
|
||||
fallback = 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;
|
||||
}
|
48
modules/base/locale/default.nix
Normal file
48
modules/base/locale/default.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.roles.base;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
fonts = {
|
||||
fontconfig = {
|
||||
enable = true;
|
||||
defaultFonts = {
|
||||
emoji = ["Noto Color Emoji"];
|
||||
monospace = ["JetBrainsMono Nerd Font"];
|
||||
sansSerif = ["Noto Nerd Font"];
|
||||
serif = ["Noto Nerd Font"];
|
||||
};
|
||||
};
|
||||
|
||||
packages = with pkgs;
|
||||
[
|
||||
noto-fonts
|
||||
noto-fonts-cjk-sans
|
||||
noto-fonts-emoji
|
||||
liberation_ttf
|
||||
font-awesome
|
||||
meslo-lgs-nf
|
||||
jetbrains-mono
|
||||
ubuntu_font_family
|
||||
]
|
||||
++ (with pkgs.nerd-fonts; [
|
||||
jetbrains-mono
|
||||
go-mono
|
||||
iosevka
|
||||
symbols-only
|
||||
space-mono
|
||||
ubuntu
|
||||
noto
|
||||
]);
|
||||
};
|
||||
|
||||
# Select internationalisation properties.
|
||||
i18n.defaultLocale = "en_CA.UTF-8";
|
||||
console.useXkbConfig = true;
|
||||
}
|
82
modules/base/locate/default.nix
Normal file
82
modules/base/locate/default.nix
Normal file
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) concatStringsSep getName mkIf;
|
||||
|
||||
baseCfg = config.roles.base;
|
||||
cfg = config.services.locate;
|
||||
|
||||
locateGroup = getName cfg.package.name;
|
||||
|
||||
locate = "${cfg.package}/bin/locate";
|
||||
updatedb = "${cfg.package}/bin/updatedb";
|
||||
|
||||
database = "/var/lib/locate/locatedb";
|
||||
pruneFS = concatStringsSep " " cfg.pruneFS;
|
||||
pruneNames = concatStringsSep " " cfg.pruneNames;
|
||||
prunePaths = concatStringsSep " " cfg.prunePaths;
|
||||
|
||||
updatedbBin = ''
|
||||
${updatedb} -o ${database} --prunefs "${pruneFS}" \
|
||||
--prunepaths "${prunePaths}" --prunenames "${pruneNames}"
|
||||
'';
|
||||
in
|
||||
mkIf (baseCfg.enable) {
|
||||
users.users.${baseCfg.user}.extraGroups = [
|
||||
locateGroup
|
||||
];
|
||||
|
||||
# TODO: add timer
|
||||
systemd.services.locate = {
|
||||
wantedBy = ["default.target"];
|
||||
serviceConfig = {
|
||||
User = baseCfg.user;
|
||||
Group = locateGroup;
|
||||
StateDirectory = "locate";
|
||||
StateDirectoryMode = "0770";
|
||||
ExecStart = updatedbBin;
|
||||
};
|
||||
};
|
||||
|
||||
home-manager.users.${baseCfg.user}.programs.bash.shellAliases = {
|
||||
locate = "${pkgs.writeShellScriptBin "lct" ''
|
||||
exec ${locate} -d ${database} "$@" 2> >(grep -v "/var/cache/locatedb")
|
||||
''}/bin/lct";
|
||||
|
||||
updatedb = updatedbBin;
|
||||
};
|
||||
|
||||
services.locate = {
|
||||
enable = true;
|
||||
package = pkgs.mlocate;
|
||||
localuser = null;
|
||||
interval = "never";
|
||||
|
||||
prunePaths = [
|
||||
"/var/lib/flatpak"
|
||||
|
||||
# Defaults
|
||||
"/tmp"
|
||||
"/var/tmp"
|
||||
"/var/cache"
|
||||
"/var/lock"
|
||||
"/var/run"
|
||||
"/var/spool"
|
||||
"/nix/var/log/nix"
|
||||
];
|
||||
|
||||
pruneNames = [
|
||||
"node_modules"
|
||||
|
||||
# Defaults
|
||||
".bzr"
|
||||
".cache"
|
||||
".git"
|
||||
".hg"
|
||||
".svn"
|
||||
];
|
||||
};
|
||||
}
|
145
modules/base/packages/default.nix
Normal file
145
modules/base/packages/default.nix
Normal file
|
@ -0,0 +1,145 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) attrValues makeBinPath mkIf optional;
|
||||
|
||||
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
|
||||
;
|
||||
});
|
||||
|
||||
# FIXME: Omnisharp uses dotnet6
|
||||
nixpkgs.config.permittedInsecurePackages = [
|
||||
"dotnet-core-combined"
|
||||
"dotnet-sdk-6.0.428"
|
||||
"dotnet-sdk-wrapped-6.0.428"
|
||||
];
|
||||
|
||||
environment.systemPackages =
|
||||
(optional (cfg.user != "nixos") (self.inputs.nurl.packages.${pkgs.system}.default.overrideAttrs {
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/nurl \
|
||||
--prefix PATH : ${makeBinPath [
|
||||
(config.home-manager.users.${cfg.user}.programs.git.package or pkgs.gitMinimal)
|
||||
(config.nix.package or pkgs.nix)
|
||||
pkgs.mercurial
|
||||
]}
|
||||
installManPage artifacts/nurl.1
|
||||
installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl
|
||||
'';
|
||||
}))
|
||||
++ (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
|
||||
;
|
||||
})
|
||||
++ [
|
||||
# TODO: `depOf` program that looks through `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;
|
||||
}
|
52
modules/base/substituters/default.nix
Normal file
52
modules/base/substituters/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) elem foldl isList mergeAttrsWithFunc mkIf optionals unique;
|
||||
|
||||
cfg = config.roles.base;
|
||||
|
||||
mergeAttrsList = list:
|
||||
foldl (mergeAttrsWithFunc (a: b:
|
||||
if isList a && isList b
|
||||
then unique (a ++ b)
|
||||
else b)) {}
|
||||
list;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "rebuild-no-cache";
|
||||
runtimeInputs = [config.programs.nh.package];
|
||||
text = ''
|
||||
exec nh os switch -- --option binary-caches "https://cache.nixos.org" "$@"
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
nix = {
|
||||
settings = let
|
||||
mkSubstituterConf = prio: url: key: {
|
||||
substituters = ["${url}?priority=${toString prio}"];
|
||||
trusted-public-keys = optionals (key != null) [key];
|
||||
};
|
||||
in
|
||||
mergeAttrsList ([
|
||||
(mkSubstituterConf 1000 "https://cache.nixos.org" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=")
|
||||
(mkSubstituterConf 1000 "https://hyprland.cachix.org" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=")
|
||||
(mkSubstituterConf 1000 "https://nix-gaming.cachix.org" "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=")
|
||||
(mkSubstituterConf 1000 "https://nixpkgs-wayland.cachix.org" "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=")
|
||||
(mkSubstituterConf 1000 "https://nix-community.cachix.org" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=")
|
||||
(mkSubstituterConf 1000 "https://viperml.cachix.org" "viperml.cachix.org-1:qZhKBMTfmcLL+OG6fj/hzsMEedgKvZVFRRAhq7j8Vh8=")
|
||||
(mkSubstituterConf 1000 "https://cuda-maintainers.cachix.org" "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=")
|
||||
]
|
||||
++ optionals (config.networking.hostName != "servivi") [
|
||||
(mkSubstituterConf 100 "https://cache.nelim.org" "cache.nelim.org:JmFqkUdH11EA9EZOFAGVHuRYp7EbsdJDHvTQzG2pPyY=")
|
||||
]
|
||||
++ optionals (elem config.networking.hostName ["bbsteamie" "binto" "wim"]) [
|
||||
(mkSubstituterConf 10 "https://cache-apt.nelim.org" "cache-apt.nelim.org:NLAsWxa2Qbm4b+hHimjCpZfm48a4oN4O/GPZY9qpjNw=")
|
||||
]);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue