nix: Modules system

This commit is contained in:
Geoffrey Frogeye 2023-10-22 19:54:59 +02:00
parent 0aed911875
commit 96a11d9975
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
4 changed files with 165 additions and 122 deletions

View file

@ -1,123 +1,9 @@
{ config, pkgs, ... }:
{
boot.loader.grub.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos";
networking.wireless.enable = true; # Enable wireless support via wpa_supplicant
time.timeZone = "Europe/Amsterdam";
# TODO qwerty-fr for console
# Enable the X11 windowing system
services.xserver.enable = true;
# FIXME qwerty-fr for X11
# Enable CUPS to print documents
services.printing.enable = true;
# Enable sound
sound.enable = true;
hardware.pulseaudio.enable = true;
services.xserver.displayManager.startx.enable = true;
services.xserver.windowManager.i3.enable = true;
# Enable passwordless sudo
security.sudo.extraRules = [
{ groups = ["wheel"]; commands = [ { command = "ALL"; options = ["NOPASSWD"]; } ]; }
];
# Users
users.users.geoffrey = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [
# dotfiles dependencies
coreutils
bash
gnugrep
gnused
gnutar
openssl
git
wget
curl
python3Packages.pip
ansible # TODO Reevaluate
# shell
zsh-completions
nix-zsh-completions
zsh-history-substring-search
antigen # TODO Reevaluate
powerline-go
# terminal essentials
moreutils
man
visidata
nodePackages.insect
translate-shell
unzip
unrar
p7zip
# remote
openssh
rsync
tigervnc # FIXME Only with display server
# DEBUG
firefox
tree
lolcat
];
initialPassword = "cartable"; # DEBUG
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPE41gxrO8oZ5n3saapSwZDViOQphm6RzqgsBUyA88pU geoffrey@frogeye.fr"
];
};
environment.systemPackages = with pkgs; [
neovim
wget
];
# Enable compilation cache
programs = {
ccache.enable = true;
# TODO Not enough, see https://nixos.wiki/wiki/CCache.
# Might want to see if it's worth using on NixOS
gnupg.agent.enable = true;
# TODO Below should be user config
zsh = {
enable = true;
autosuggestions.enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
};
neovim = {
enable = true;
defaultEditor = true;
vimAlias = true;
viAlias = true;
};
};
services = {
# Enable the OpenSSH daemon
openssh.enable = true;
getty.autologinUser = "geoffrey"; # DEBUG
};
# TEST
system.copySystemConfiguration = true;
# Use defaults from
system.stateVersion = "23.05";
}
let
recursiveMerge = import ./recursiveMerge.nix;
getModule = name: import (./modules + "/${name}.nix") { inherit config pkgs; };
in
recursiveMerge [
(getModule "common")
(getModule "x11")
]

View file

@ -0,0 +1,112 @@
{ pkgs, ... }:
{
boot.loader.grub.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos";
networking.wireless.enable = true; # Enable wireless support via wpa_supplicant
time.timeZone = "Europe/Amsterdam";
# TODO qwerty-fr for console
# Enable CUPS to print documents
services.printing.enable = true;
# Enable passwordless sudo
security.sudo.extraRules = [{
groups = [ "wheel" ];
commands = [{
command = "ALL";
options = [ "NOPASSWD" ];
}];
}];
# Users
users.users.geoffrey = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [
# dotfiles dependencies
coreutils
bash
gnugrep
gnused
gnutar
openssl
git
wget
curl
python3Packages.pip
ansible # TODO Reevaluate
# shell
zsh-completions
nix-zsh-completions
zsh-history-substring-search
antigen # TODO Reevaluate
powerline-go
# terminal essentials
moreutils
man
visidata
nodePackages.insect
translate-shell
unzip
unrar
p7zip
# remote
openssh
rsync
# DEBUG
tree
lolcat
];
initialPassword = "cartable"; # DEBUG
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPE41gxrO8oZ5n3saapSwZDViOQphm6RzqgsBUyA88pU geoffrey@frogeye.fr"
];
};
environment.systemPackages = with pkgs; [ neovim wget ];
# Enable compilation cache
programs = {
ccache.enable = true;
# TODO Not enough, see https://nixos.wiki/wiki/CCache.
# Might want to see if it's worth using on NixOS
gnupg.agent.enable = true;
# TODO Below should be user config
zsh = {
enable = true;
autosuggestions.enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
};
neovim = {
enable = true;
defaultEditor = true;
vimAlias = true;
viAlias = true;
};
};
services = {
# Enable the OpenSSH daemon
openssh.enable = true;
getty.autologinUser = "geoffrey"; # DEBUG
};
# TEST
system.copySystemConfiguration = true;
# Use defaults from
system.stateVersion = "23.05";
}

View file

@ -0,0 +1,22 @@
{ pkgs, ... }:
{
# Enable the X11 windowing system
services.xserver.enable = true;
# FIXME qwerty-fr for X11
# Enable sound
sound.enable = true;
hardware.pulseaudio.enable = true;
services.xserver.displayManager.startx.enable = true;
services.xserver.windowManager.i3.enable = true;
users.users.geoffrey. packages = with pkgs; [
# remote
tigervnc
# remote
firefox
];
}

View file

@ -0,0 +1,23 @@
let
pkgs = import <nixpkgs> { };
# Somehow, if fed the pkgs from a nix-build, it creates an infinite recursion, hence the search path
lib = pkgs.lib;
recursiveMerge = with lib; attrList:
let f = attrPath:
zipAttrsWith (n: values:
if tail values == [ ]
then head values
else if all isList values
then unique (concatLists values)
else if all isAttrs values
then f (attrPath ++ [ n ]) values
else last values
);
in f [ ] attrList;
in
recursiveMerge