modules: move devos/* into global

This commit is contained in:
Infinidoge 2023-07-29 16:31:33 -04:00
parent 80d2277a16
commit 7c9c18e578
7 changed files with 1 additions and 10 deletions

View file

@ -0,0 +1,11 @@
{ lib, ... }:
let
folder = ./.;
toImport = name: value: folder + ("/" + name);
filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key && key != "default.nix";
imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder));
in
{
inherit imports;
nix.settings.substituters = lib.mkBefore [ "https://cache.nixos.org/" ];
}

View file

@ -0,0 +1,10 @@
{
nix.settings = {
substituters = [
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
}

View file

@ -0,0 +1,10 @@
{
nix.settings = {
substituters = [
"https://nrdxp.cachix.org"
];
trusted-public-keys = [
"nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4="
];
};
}

View file

@ -0,0 +1,12 @@
{ config, lib, ... }:
{
nix.settings = {
substituters = lib.mkIf (config.networking.hostName != "Infini-DESKTOP" && config.info.loc.home)
((if config.info.loc.home then (lib.mkOrder 300) else lib.mkAfter) [
"ssh://infini-desktop"
]);
trusted-public-keys = [
"infinidoge-1:uw2A6JHHdGJ9GPk0NEDnrdfVkPp0CUY3zIvwVgNlrSk="
];
};
}

View file

@ -0,0 +1,39 @@
{ config, lib, pkgs, ... }: {
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = {
main = config;
};
sharedModules = [
{
home = {
stateVersion = config.system.stateVersion;
sessionVariables = {
inherit (config.environment.sessionVariables) NIX_PATH;
};
};
xdg = {
enable = true;
configFile = {
"nix/registry.json".text = config.environment.etc."nix/registry.json".text;
"nixpkgs/config.nix".text = lib.generators.toPretty { } {
allowUnfree = true;
};
};
};
}
(lib.mkIf config.services.xserver.enable {
xsession.enable = true;
})
(lib.mkIf config.info.graphical {
xdg.systemDirs.data = [
"${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}"
"${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}"
];
})
];
};
}

95
modules/global/nix.nix Normal file
View file

@ -0,0 +1,95 @@
{ config, channel, inputs, pkgs, lib, self, ... }:
with lib;
{
nix = {
package = pkgs.nixUnstable;
settings = {
allowed-users = [ "@wheel" ];
trusted-users = [ "root" "@wheel" ];
system-features = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
auto-optimise-store = true;
sandbox = true;
};
gc = {
automatic = true;
options = "--delete-older-than 3d";
dates = "weekly";
};
optimise.automatic = true;
registry =
let
flakes = filterAttrs (n: v: v ? outputs) inputs;
in
builtins.mapAttrs (_n: v: { flake = v; }) flakes;
extraOptions = ''
extra-experimental-features = flakes nix-command
extra-substituters = https://nrdxp.cachix.org https://nix-community.cachix.org
extra-trusted-public-keys = nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
min-free = 536870912
keep-outputs = true
keep-derivations = true
fallback = true
'' + (if config.modules.secrets.enable then ''
secret-key-files = ${config.secrets.binary-cache-private-key}
'' else "");
localRegistry = {
enable = true;
cacheGlobalRegistry = true;
};
};
nixpkgs.config = {
allowUnfree = true;
};
environment = {
systemPackages = with pkgs; [
nix-index
nixos-option
nixfmt
nixpkgs-fmt
nix-du
comma
(writeScriptBin "wherenix" ''
#!/usr/bin/env bash
${unixtools.whereis}/bin/whereis "''${@}" \
| ${gawk}/bin/awk '{ print substr($0, length($1)+2) }' \
| ${findutils}/bin/xargs -r ${coreutils}/bin/readlink -f \
| ${coreutils}/bin/sort \
| ${coreutils}/bin/uniq
'')
];
shellAliases =
let ifSudo = mkIf config.security.sudo.enable;
in
{
# nix
n = "nix";
ns = "n search --no-update-lock-file";
nf = "n flake";
nepl = "n repl '<nixpkgs>'";
srch = "ns nixpkgs";
nrb = ifSudo "sudo nixos-rebuild";
mn = ''
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
'';
# fix nixos-option
# nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
};
};
}

View file

@ -0,0 +1,55 @@
# Heavily inspired by hlissner: https://github.com/hlissner/dotfiles/blob/master/modules/options.nix
{ config, options, lib, home-manager, ... }:
with lib;
with lib.hlissner;
let
mkAliasOpt = mkOpt types.attrs { };
mkInfoOpt = mkOpt types.str "";
in
{
options = with types; {
user = mkAliasOpt;
home = mkAliasOpt;
dotfiles = {
dir = mkOpt str "/etc/nixos";
homeFile = mkAliasOpt;
configFile = mkAliasOpt;
dataFile = mkAliasOpt;
};
env = mkAliasOpt;
info = {
monitors = mkOpt int 1;
graphical = mkBoolOpt config.services.xserver.enable;
model = mkOpt types.str "A Computer";
env = {
wm = mkInfoOpt;
};
stationary = mkBoolOpt false;
loc = {
home = mkBoolOpt config.info.stationary;
};
};
secrets = mkOpt (attrsOf path) { };
};
config = {
users.users.${config.user.name} = mkAliasDefinitions options.user;
home-manager.users.${config.user.name} = mkAliasDefinitions options.home;
home = {
home.file = mkAliasDefinitions options.dotfiles.homeFile;
xdg = {
configFile = mkAliasDefinitions options.dotfiles.configFile;
dataFile = mkAliasDefinitions options.dotfiles.dataFile;
};
};
environment.variables = mkAliasDefinitions options.env;
secrets = mapAttrs (n: v: v.path) config.age.secrets;
};
}