diff --git a/config/nix/configuration.nix b/config/nix/configuration.nix index f44aeec..2c067b8 100644 --- a/config/nix/configuration.nix +++ b/config/nix/configuration.nix @@ -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") +] diff --git a/config/nix/modules/common.nix b/config/nix/modules/common.nix new file mode 100644 index 0000000..e71861c --- /dev/null +++ b/config/nix/modules/common.nix @@ -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"; + +} diff --git a/config/nix/modules/x11.nix b/config/nix/modules/x11.nix new file mode 100644 index 0000000..5bde7b1 --- /dev/null +++ b/config/nix/modules/x11.nix @@ -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 + ]; +} diff --git a/config/nix/recursiveMerge.nix b/config/nix/recursiveMerge.nix new file mode 100644 index 0000000..6c3d87d --- /dev/null +++ b/config/nix/recursiveMerge.nix @@ -0,0 +1,23 @@ +let + + pkgs = import { }; + # 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