add home-manager

This commit is contained in:
Dennis Wuitz 2023-12-25 03:39:20 +01:00
parent c6c879ddb4
commit e08f011d28
7 changed files with 112 additions and 97 deletions

44
flake.lock generated
View File

@ -1,5 +1,41 @@
{ {
"nodes": { "nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1703368619,
"narHash": "sha256-ZGPMYL7FMA6enhuwby961bBANmoFX14EA86m2/Jw5Jo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a2523ea0343b056ba240abbac90ab5f116a7aa7b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1702453208,
"narHash": "sha256-0wRi9SposfE2wHqjuKt8WO2izKB/ASDOV91URunIqgo=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "7763c6fd1f299cb9361ff2abf755ed9619ef01d6",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixos-modules": { "nixos-modules": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -7,11 +43,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1703443084, "lastModified": 1703466232,
"narHash": "sha256-POWXUw4gf8c9eZ1PJ2Har+PBsgdyULeHbqabdVSAQZE=", "narHash": "sha256-euLiyAHlppxizV0aRHx9adR4fTTLQVFL5sJ4LWn6dTQ=",
"owner": "SuperSandro2000", "owner": "SuperSandro2000",
"repo": "nixos-modules", "repo": "nixos-modules",
"rev": "55e8b1d38fe4a5e0315f91dfc44bd1a6f32b06ef", "rev": "d428b73701f49f1fe5f47720db4d093d60818f18",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -38,6 +74,8 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager",
"nixos-hardware": "nixos-hardware",
"nixos-modules": "nixos-modules", "nixos-modules": "nixos-modules",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"

View File

@ -3,12 +3,18 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
nixos-modules = { nixos-modules = {
url = "github:SuperSandro2000/nixos-modules"; url = "github:SuperSandro2000/nixos-modules";
inputs.nixpkgs-lib.follows = "nixpkgs"; inputs.nixpkgs-lib.follows = "nixpkgs";
}; };
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = { sops-nix = {
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs = { inputs = {
@ -18,7 +24,7 @@
}; };
}; };
outputs = { nixpkgs, nixos-modules, sops-nix, ... }: outputs = { nixpkgs, nixos-hardware, nixos-modules, home-manager, sops-nix, ... }:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
src = builtins.filterSource (path: type: type == "directory" || lib.hasSuffix ".nix" (baseNameOf path)) ./.; src = builtins.filterSource (path: type: type == "directory" || lib.hasSuffix ".nix" (baseNameOf path)) ./.;
@ -30,27 +36,34 @@
hostname, hostname,
system ? "x86_64-linux", system ? "x86_64-linux",
modules ? [], modules ? [],
users ? [], users ? ["dennis"],
}: lib.nixosSystem { }: lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
nixos-modules.nixosModule nixos-modules.nixosModule
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
./systems/programs.nix ./systems/programs.nix
./systems/configuration.nix ./systems/configuration.nix
./systems/${hostname}/hardware.nix ./systems/${hostname}/hardware.nix
./systems/${hostname}/configuration.nix ./systems/${hostname}/configuration.nix
] ++ modules ++ fileList "modules" ++ map(user: ./users/${user}) users; { config.networking.hostName = "${hostname}"; }
] ++ modules ++ fileList "modules"
++ map(user: { config, lib, pkgs, ... }@args: {
users.users.${user} = import ./users/${user} (args // { name = "${user}"; });
}) users
++ map(user: { home-manager.users.${user} = import ./users/${user}/home.nix; }) users;
}; };
in { in {
photon = constructSystem { photon = constructSystem {
hostname = "photon"; hostname = "photon";
users = ["dennis"];
}; };
palatine-hill = constructSystem { palatine-hill = constructSystem {
hostname = "palatine-hill"; hostname = "palatine-hill";
users = ["alice"];
}; };
}; };
}; };

View File

@ -7,6 +7,12 @@ in
options = { options = {
boot = { boot = {
default = libS.mkOpinionatedOption "enable the boot builder"; default = libS.mkOpinionatedOption "enable the boot builder";
cpuType = lib.mkOption {
type = lib.types.str;
example = "amd";
default = "";
description = "The cpu-type installed on the server.";
};
}; };
}; };
@ -14,8 +20,8 @@ in
supportedFilesystems = [ "zfs" ]; supportedFilesystems = [ "zfs" ];
tmp.useTmpfs = true; tmp.useTmpfs = true;
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
kernelParams = [ "kvm-amd" "nordrand" ]; kernelParams = [ "nordrand" ] ++ lib.optional (cfg.cpuType == "amd") "kvm-amd";
zfs = { zfs = {
enableUnstable = true; enableUnstable = true;
devNodes = "/dev/disk/by-id/"; devNodes = "/dev/disk/by-id/";
forceImportRoot = true; forceImportRoot = true;

View File

@ -2,16 +2,18 @@
{ {
i18n = { i18n = {
defaultLocale = "en_US.utf8"; defaultLocale = "en_US.utf8";
supportedLocales = [ supportedLocales = [ "en_US.UTF-8/UTF-8" ];
"en_US.UTF-8/UTF-8"
"de_DE.UTF-8/UTF-8"
];
}; };
boot = { boot = {
default = true; default = true;
}; };
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
};
networking.firewall.allowedTCPPorts = [ 22 ]; networking.firewall.allowedTCPPorts = [ 22 ];
services = { services = {
@ -31,18 +33,10 @@
programs = { programs = {
fzf.keybindings = true; fzf.keybindings = true;
git = { git = {
enable = true; enable = true;
config = { config = {
alias = {
p = "pull";
r = "reset --hard";
ci = "commit";
co = "checkout";
lg = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'";
st = "status";
undo = "reset --soft HEAD^";
};
interactive.singlekey = true; interactive.singlekey = true;
pull.rebase = true; pull.rebase = true;
rebase.autoStash = true; rebase.autoStash = true;
@ -50,6 +44,21 @@
}; };
}; };
neovim = {
enable = true;
defaultEditor = true;
configure = {
customRC = ''
set undofile " save undo file after quit
set undolevels=1000 " number of steps to save
set undoreload=10000 " number of lines to save
" Save Cursor Position
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
'';
};
};
zsh = { zsh = {
enable = true; enable = true;
autosuggestions = { autosuggestions = {
@ -64,69 +73,7 @@
enableBashCompletion = true; enableBashCompletion = true;
ohMyZsh = { ohMyZsh = {
enable = true; enable = true;
plugins = [ "git" "sudo" "docker" "kubectl" "history" "colorize" "direnv" ];
theme = "agnoster";
}; };
shellAliases = {
flake = "nvim flake.nix";
garbage = "sudo nix-collect-garbage -d";
gpw = "git pull | grep \"Already up-to-date\" > /dev/null; while [ $? -gt 1 ]; do sleep 5; git pull | grep \"Already up-to-date\" > /dev/null; done; notify-send Pull f$";
l = "ls -lah";
nixdir = "echo \"use flake\" > .envrc && direnv allow";
nixeditc = "nvim ~/dotfiles/system/configuration.nix";
nixeditpc = "nvim ~/dotfiles/system/program.nix";
pypi = "pip install --user";
qr = "qrencode -m 2 -t utf8 <<< \"$1\"";
update = "sudo nixos-rebuild switch --fast --flake ~/dotfiles/ -L";
v = "nvim";
};
};
neovim = {
enable = true;
defaultEditor = true;
vimAlias = true;
viAlias = true;
withPython3 = true;
configure = {
customRC = ''
set undofile " save undo file after quit
set undolevels=1000 " number of steps to save
set undoreload=10000 " number of lines to save
" Save Cursor Position
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
'';
packages.myVimPackage = with pkgs.vimPlugins; {
start = [
colorizer
copilot-vim
csv-vim
fugitive
fzf-vim
nerdtree
nvchad
nvchad-ui
nvim-treesitter-refactor
nvim-treesitter.withAllGrammars
unicode-vim
vim-cpp-enhanced-highlight
vim-tmux
vim-tmux-navigator
];
};
};
};
tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [
nord
vim-tmux-navigator
sensible
yank
];
}; };
nix-ld = { nix-ld = {
@ -170,7 +117,7 @@
gc = { gc = {
automatic = true; automatic = true;
dates = "weekly"; dates = "weekly";
options = "--delete-oder-than 14d"; options = "--delete-oder-than 30d";
}; };
diffSystem = true; diffSystem = true;

View File

@ -1,8 +1,5 @@
{ pkgs, lib, config }: { pkgs, lib, config, name, ... }:
import ../default.nix { import ../default.nix {
inherit pkgs lib config; inherit pkgs lib config name;
userName = "AmethystAndroid"; pubKeys = [ "ed25516-AAAAAAA" ];
pubKeys = {
palatine-hill = "ed25516-AAAAAAA";
};
} }

7
users/alice/home.nix Normal file
View File

@ -0,0 +1,7 @@
{ ... }:
{
programs = {
};
home.stateVersion = "23.11";
}

View File

@ -1,5 +1,14 @@
{ lib, config, pkgs, userName, pubKeys }:
{ {
lib,
config,
pkgs,
name,
pubKeys ? [],
defaultShell ? "zsh",
}:
{
inherit name;
isNormalUser = true; isNormalUser = true;
uid = 1000; uid = 1000;
extraGroups = [ extraGroups = [
@ -8,14 +17,12 @@
(lib.mkIf config.networking.networkmanager.enable "networkmanager") (lib.mkIf config.networking.networkmanager.enable "networkmanager")
(lib.mkIf config.programs.adb.enable "adbusers") (lib.mkIf config.programs.adb.enable "adbusers")
(lib.mkIf config.programs.wireshark.enable "wireshark") (lib.mkIf config.programs.wireshark.enable "wireshark")
(lib.mkIf config.programs.virtualisation.docker.enable "docker") (lib.mkIf config.virtualisation.docker.enable "docker")
"libvirtd" "libvirtd"
"dialout" "dialout"
"plugdev" "plugdev"
"uaccess" "uaccess"
]; ];
shell = pkgs.zsh; shell = pkgs.${defaultShell};
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keys = pubKeys;
(lib.mkIf (pubKeys ? ${config.networking.hostName}) pubKeys.${config.networking.hostName})
];
} }