systems -> hosts

moved functions to /lib

inputs over imports

turned each module file into a nixosModule

moved registry and $NIX_PATH pinning to /modules/pinning.nix
This commit is contained in:
Gerg-L 2023-06-22 22:55:43 -04:00
parent ee2beea680
commit f43d0b741c
42 changed files with 224 additions and 240 deletions

View file

@ -1,9 +1,11 @@
{
inputs,
suckless,
self,
...
}: {
pkgs,
config,
lib,
self,
...
}: {
options.localModules.DE.dwm.enable = lib.mkEnableOption "";
@ -45,7 +47,7 @@
};
environment.systemPackages = builtins.attrValues {
inherit
(inputs.suckless.packages.${pkgs.system})
(suckless.packages.${pkgs.system})
dmenu
dwm
st

View file

@ -1,4 +1,4 @@
{
_: {
config,
lib,
pkgs,

View file

@ -1,4 +1,4 @@
{
_: {
config,
lib,
pkgs,

View file

@ -1,4 +1,4 @@
{
_: {
config,
lib,
...

View file

@ -1,7 +1,6 @@
{
{self, ...}: {
config,
lib,
self,
pkgs,
...
}: {

View file

@ -1,4 +1,4 @@
{
_: {
config,
pkgs,
lib,

View file

@ -1,5 +1,4 @@
{
self,
{self, ...}: {
lib,
pkgs,
...

View file

@ -1,15 +1,16 @@
{
inputs,
{unstable, ...}: {
lib,
config,
pkgs,
...
}: let
}:
#TAKEN FROM https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/stage-2.nix
let
useHostResolvConf = config.networking.resolvconf.enable && config.networking.useHostResolvConf;
bootStage2 = pkgs.substituteAll {
src = pkgs.runCommand "stage-2-init.sh" {} ''
sed '2i exec 1<>/dev/null' ${inputs.unstable}/nixos/modules/system/boot/stage-2-init.sh > $out
sed '2i exec 1<>/dev/null' ${unstable}/nixos/modules/system/boot/stage-2-init.sh > $out
'';
shellDebug = "${pkgs.bashInteractive}/bin/bash";
shell = "${pkgs.bash}/bin/bash";

View file

@ -1,4 +1,4 @@
{
_: {
config,
lib,
...

27
modules/direnv.nix Normal file
View file

@ -0,0 +1,27 @@
_: {pkgs, ...}: {
environment = {
systemPackages = builtins.attrValues {
inherit
(pkgs)
nix-direnv
direnv
;
};
variables = {
DIRENV_LOG_FORMAT = "";
DIRENV_CONFIG = "${pkgs.nix-direnv}/share/nix-direnv";
};
};
programs = {
zsh.interactiveShellInit = ''
eval "$(direnv hook zsh)"
'';
bash.interactiveShellInit = ''
eval "$(direnv hook bash)"
'';
fish.interactiveShellInit = ''
direnv hook fish | source
'';
};
}

View file

@ -1,4 +1,4 @@
{
_: {
pkgs,
config,
lib,

View file

@ -1,4 +1,4 @@
{
_: {
config,
lib,
...

View file

@ -1,4 +1,4 @@
{
_: {
lib,
config,
pkgs,

View file

@ -1,34 +1,4 @@
{
pkgs,
inputs,
lib,
self,
...
}: let
combined_flakes =
(
#filter non-flakes from inputs
lib.filterAttrs (
_: value: (
!(lib.hasAttrByPath ["flake"] value) || !value.flake
)
)
inputs
)
// {
#alias unstable
nixpkgs = inputs.unstable;
#add system flake
system = self;
};
in {
#create registry from input flakes
nix.registry = lib.mapAttrs (_: value: {flake = value;}) combined_flakes;
#add all inputs to etc
environment.etc = lib.mapAttrs' (name: value: lib.nameValuePair "/nixpath/${name}" {source = value;}) combined_flakes;
#source the etc paths to nixPath
nix.nixPath = lib.mapAttrsToList (name: _: name + "=/etc/nixpath/${name}") combined_flakes;
inputs: {pkgs, ...}: {
#other nix settings
nix = {
package = inputs.nix.packages.${pkgs.system}.default;

12
modules/pinning.nix Normal file
View file

@ -0,0 +1,12 @@
inputs: {lib, ...}: let
alias = inputs // {nixpkgs = inputs.unstable;};
in
lib.pipe alias [
(lib.filterAttrs (_: v: v._type == "flake"))
(lib.mapAttrsToList (n: input: {
environment.etc."nixpath/${n}".source = input.outPath;
nix.nixPath = ["${n}=/etc/nixpath/${n}"];
nix.registry.${n}.flake = input;
}))
lib.mkMerge
]

View file

@ -1,5 +1,4 @@
{
inputs,
{fetch-rs, ...}: {
pkgs,
config,
lib,
@ -11,11 +10,9 @@
(pkgs)
page
exa
direnv
nix-direnv
;
inherit
(inputs.fetch-rs.packages.${pkgs.system})
(fetch-rs.packages.${pkgs.system})
fetch-rs
;
};
@ -25,13 +22,13 @@
VISUAL = "nvim";
PAGER = "page";
SYSTEMD_PAGERSECURE = "true";
DIRENV_LOG_FORMAT = "";
};
shellAliases = {
#make sudo use aliases
sudo = "sudo ";
#paste link trick
pastebin = "curl -F 'clbin=<-' https://clbin.com";
termbin = "nc termbin.com 9999";
#nix stuff
gc-check = "nix-store --gc --print-roots | egrep -v \"^(/nix/var|/run/\w+-system|\{memory|/proc)\"";
#vim stuff
@ -49,9 +46,6 @@
lt = "exa --tree --level=2";
};
interactiveShellInit = "fetch-rs";
pathsToLink = [
"/share/nix-direnv"
];
};
security.sudo = {
enable = true;
@ -72,24 +66,29 @@
syntaxHighlighting.enable = true;
histSize = 10000;
histFile = "$HOME/.cache/zsh_history";
shellInit = ''
eval "$(direnv hook zsh)"
'';
};
#starship
starship = {
enable = true;
settings = {
add_newline = false;
format = "$sudo\${custom.direnv} $cmd_duration \n $directory$git_branch$character";
format = "$sudo$nix_shell\${custom.direnv}$cmd_duration\n$git_metrics$git_state$git_branch\n$directory$character";
character = {
success_symbol = "[ ](#9ece6a bold)";
error_symbol = "[ ](#db4b4b bold)";
success_symbol = "[\\$](#9ece6a bold)";
error_symbol = "[\\$](#db4b4b bold)";
};
nix_shell = {
format = "[󱄅 ](#74b2ff)";
heuristic = true;
};
directory = {
read_only = " ";
};
git_metrics = {
disabled = false;
};
git_branch = {
format = "[$symbol$branch(:$remote_branch)]($style)";
style = "bold red";
};
sudo = {
@ -103,7 +102,7 @@
custom.direnv = {
format = "[\\[direnv\\]]($style)";
style = "#36c692";
detect_folders = [".direnv"];
when = "printenv DIRENV_FILE";
};
};
};

View file

@ -1,18 +1,20 @@
{
inputs,
pkgs,
sops-nix,
self,
...
}: {
pkgs,
config,
...
}: {
imports = [
inputs.sops-nix.nixosModules.sops
sops-nix.nixosModules.sops
];
environment.systemPackages = [
pkgs.sops
];
sops = {
defaultSopsFile = self + "/systems/" + config.networking.hostName + "/secrets.yaml";
defaultSopsFile = self + "/hosts/" + config.networking.hostName + "/secrets.yaml";
age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];
};
}

View file

@ -1,4 +1,4 @@
{
_: {
pkgs,
config,
lib,