Commit 519c3b6ce7c6
Changed files (28)
systems
hosts
modules
desktop
editors
hardware
shell
users
vincent
systems/hosts/foo.flake.nix
@@ -12,9 +12,36 @@ let
endpointPublicKey = strings.optionalString secretCondition (import secretPath).wireguard.kerkouane.publicKey;
in
{
- profiles.laptop.enable = true;
- profiles.desktop.i3.enable = true;
- profiles.home.enable = true;
+ modules = {
+ desktop = {
+ i3.enable = true;
+ };
+ editors = {
+ default = "vim";
+ vim.enable = true;
+ };
+ hardware = {
+ bluetooth.enable = true;
+ audio.enable = true;
+ yubikey.enable = true;
+ };
+ shell = {
+ direnv.enable = true;
+ git.enable = true;
+ gnupg.enable = true;
+ tmux.enable = true;
+ zsh.enable = true;
+ };
+ virtualisation = {
+ enable = true;
+ nested = true;
+ };
+ };
+ profiles = {
+ home.enable = true;
+ redhat.enable = true;
+ laptop.enable = true;
+ };
environment.systemPackages = with pkgs; [ tkn nyxt ];
/*
systems/modules/profiles/desktop.flake.nix → systems/modules/desktop/base.nix
@@ -1,11 +1,11 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkEnableOption mkDefault;
- cfg = config.profiles.desktop;
+ cfg = config.modules.desktop;
in
{
options = {
- profiles.desktop = {
+ modules.desktop = {
enable = mkEnableOption "desktop configuration";
};
};
systems/modules/desktop/default.nix
@@ -0,0 +1,6 @@
+{
+ imports = [
+ ./base.nix
+ ./i3.nix
+ ];
+}
systems/modules/profiles/i3.nix → systems/modules/desktop/i3.nix
@@ -2,19 +2,18 @@
with lib;
let
- cfg = config.profiles.desktop.i3;
+ cfg = config.modules.desktop.i3;
in
{
options = {
- profiles.desktop.i3 = {
+ modules.desktop.i3 = {
enable = mkEnableOption "Enable i3 desktop profile";
};
};
config = mkIf cfg.enable {
- profiles = {
- desktop.enable = true;
- };
+ # Enable desktop modules if not already
+ modules.desktop.enable = true;
services = {
blueman.enable = true;
autorandr.enable = true;
systems/modules/editors/default.nix
@@ -0,0 +1,20 @@
+{ config, lib, ... }:
+let
+ inherit (lib) mkIf mkOption mkOverride types;
+ cfg = config.modules.editors;
+in
+{
+ imports = [ ./vim.nix ./emacs.nix ];
+ options.modules.editors = {
+ default = mkOption {
+ description = "default editor";
+ type = types.str;
+ default = "vim";
+ };
+ };
+ config = mkIf (cfg.default != null) {
+ environment.variables = {
+ EDITOR = mkOverride 0 cfg.default;
+ };
+ };
+}
systems/modules/editors/emacs.nix
@@ -0,0 +1,19 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.editors.emacs;
+in
+{
+ options.modules.editors.emacs = {
+ enable = mkEnableOption "enable emacs editor";
+ };
+ config = mkIf cfg.enable {
+ # FIXME add a default configuration
+ environment = {
+ systemPackages = [ pkgs.emacs ];
+ shellAliases = {
+ e = "emacs";
+ };
+ };
+ };
+}
systems/modules/editors/vim.nix
@@ -0,0 +1,18 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.editors.vim;
+in
+{
+ options.modules.editors.vim = {
+ enable = mkEnableOption "enable vim editor";
+ };
+ config = mkIf cfg.enable {
+ environment = {
+ systemPackages = [ pkgs.vim ];
+ shellAliases = {
+ v = "vim";
+ };
+ };
+ };
+}
systems/modules/hardware/audio.nix
@@ -0,0 +1,31 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.hardware.audio;
+in
+{
+ options.modules.hardware.audio = {
+ enable = mkEnableOption "enable audio";
+ };
+ config = mkIf cfg.enable {
+ # Add extra packages
+ environment.systemPackages = with pkgs; [
+ apulse # allow alsa application to use pulse
+ pavucontrol # pulseaudio volume control
+ pasystray # systray application
+ ];
+ # Enable sound (alsa)
+ sound.enable = true;
+ # Enable and configure pulseaudio
+ hardware.pulseaudio = {
+ enable = true;
+ support32Bit = true;
+ };
+ # FIXME is it needed
+ security.pam.loginLimits = [
+ { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
+ { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
+ { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; }
+ ];
+ };
+}
systems/modules/hardware/bluetooth.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf mkMerge;
+ cfg = config.modules.hardware.bluetooth;
+in
+{
+ options.modules.hardware.bluetooth = {
+ enable = mkEnableOption "Enable bluetooth";
+ };
+
+ config = mkIf cfg.enable (mkMerge [
+ { hardware.bluetooth.enable = true; }
+ (mkIf config.modules.hardware.audio.enable {
+ hardware.pulseaudio = {
+ # NixOS allows either a lightweight build (default) or full build of
+ # PulseAudio to be installed. Only the full build has Bluetooth
+ # support, so it must be selected here.
+ package = pkgs.pulseaudioFull;
+ # Enable additional codecs
+ extraModules = [ pkgs.pulseaudio-modules-bt ];
+ };
+
+ hardware.bluetooth.extraConfig = ''
+ [General]
+ Enable=Source,Sink,Media,Socket
+ '';
+ })
+ ]);
+}
systems/modules/hardware/default.nix
@@ -1,5 +1,8 @@
{
imports = [
+ ./audio.nix
+ ./bluetooth.nix
+ ./yubikey.nix
# remove "nixos"
./sane-extra-config.nixos.nix
];
systems/modules/profiles/yubikey.nix → systems/modules/hardware/yubikey.nix
@@ -1,12 +1,11 @@
{ config, lib, pkgs, ... }:
-
-with lib;
let
- cfg = config.profiles.yubikey;
+ inherit (lib) mkEnableOption mkIf mkMerge mkOption types;
+ cfg = config.modules.hardware.yubikey;
in
{
options = {
- profiles.yubikey = {
+ modules.hardware.yubikey = {
enable = mkEnableOption "Enable yubikey profile";
u2f = mkOption {
default = true;
systems/modules/profiles/base.flake.nix
@@ -1,12 +1,12 @@
{ config, inputs, lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkIf mkDefault mkOverride;
- cfg = config.profiles.base;
+ cfg = config.modules.base;
in
{
imports = [ inputs.home-manager.nixosModules.home-manager ];
options = {
- profiles.base = {
+ modules.base = {
enable = mkEnableOption "base configuration";
};
};
@@ -35,10 +35,6 @@ in
};
environment = {
- # Path to link from packages to /run/current-system/sw
- pathsToLink = [
- "/share/nix-direnv"
- ];
# System packages to install, those are the absolute minimum packages required
systemPackages = with pkgs; [
file
@@ -48,14 +44,8 @@ in
netcat
psmisc
pv
- vim
wget
];
- # Default editor for the system is vim
- # (for the users, that might change :D)
- variables = {
- EDITOR = mkOverride 0 "vim";
- };
};
# Home manager default configuration
systems/modules/profiles/default.flake.nix
@@ -1,15 +1,15 @@
+# Profiles are grouping modules so that we don't have to
+# specify them for all machines all the time.
{ lib, ... }:
{
imports = [
./base.flake.nix
- ./desktop.flake.nix
- ./development.flake.nix
./home.flake.nix
- ./i3.nix
./laptop.flake.nix
+ # ./desktop.flake.nix
# FIXME: vpn, server, builder, …
];
- profiles.base.enable = lib.mkDefault true;
+ modules.base.enable = lib.mkDefault true;
}
systems/modules/profiles/development.flake.nix
@@ -1,1 +0,0 @@
-{ }
systems/modules/profiles/home.flake.nix
@@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkEnableOption;
- cfg = config.profiles.home;
+ cfg = config.modules.home;
secretPath = ../../secrets/machines.nix;
secretCondition = (builtins.pathExists secretPath);
@@ -9,7 +9,7 @@ let
in
{
options = {
- profiles.home = {
+ modules.home = {
enable = mkEnableOption "home configuration";
};
};
systems/modules/profiles/laptop.flake.nix
@@ -10,7 +10,7 @@ in
};
};
config = mkIf cfg.enable {
- profiles.desktop.enable = true;
+ modules.desktop.enable = true;
nix = {
sshServe.enable = mkForce false;
};
systems/modules/shell/git/config
@@ -0,0 +1,43 @@
+[alias]
+ co = checkout
+ st = status
+ ci = commit --signoff
+ ca = commit --amend
+ b = branc --color -v
+ br = branch
+ unstage = reset HEAD
+ lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
+ lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative --branches --remotes
+ lol = log --pretty=oneline --abbrev-commit --graph --decorate
+ conflicts = !git ls-files --unmerged | cut -c51- | sort -u | xargs $EDITOR
+ resolve = !git ls-files --unmerged | cut -c51- | sort -u | xargs git add
+[color]
+ branch = auto
+ diff = auto
+ status = auto
+[color "branch"]
+ current = cyan reverse
+ local = cyan
+ remote = green
+[color "diff"]
+ meta = white reverse
+ frag = magenta reverse
+ old = red
+ new = green
+[color "status"]
+ added = green
+ changed = yellow
+ untracked = red
+[core]
+ excludesfile = /etc/gitignore
+[push]
+ default = matching
+[merge]
+ tool = vimdiff
+[user]
+ name = Vincent Demeester
+ email = vincent@sbr.pm
+[http]
+ cookiefile = /home/vincent/.gitcookies
+[url "git@github.com:"]
+ pushInsteadOf = git://github.com/
systems/modules/shell/git/ignore
@@ -0,0 +1,61 @@
+# For emacs:
+*~
+*.*~
+\#*
+.\#*
+
+# For vim:
+*.swp
+.*.sw[a-z]
+*.un~
+Session.vim
+.netrwhist
+
+# Ignore tags (from etags and ctags)
+TAGS
+!TAGS/
+tags
+!tags/
+
+# Logs and databases #
+######################
+*.log
+*.cache
+
+# OS generated files #
+######################
+.DS_Store?
+.DS_Store
+.CFUserTextEncoding
+.Trash
+.Xauthority
+thumbs.db
+Icon?
+Thumbs.db
+.cache
+.pid
+.sock
+
+# Code stuffs #
+###############
+.svn
+.git
+.swp
+.idea
+.*.swp
+*~
+.tags
+tags
+.sass-cache
+tmp
+.codekit-cache
+config.codekit
+
+# Compiled thangs #
+###################
+*.class
+*.exe
+*.o
+*.so
+*.dll
+*.pyc
systems/modules/shell/default.nix
@@ -0,0 +1,13 @@
+{ lib, ... }:
+let
+ inherit (lib) mkEnableOption;
+in
+{
+ imports = [
+ ./direnv.nix
+ ./git.nix
+ ./gnupg.nix
+ ./tmux.nix
+ ./zsh.nix
+ ];
+}
systems/modules/shell/direnv.nix
@@ -0,0 +1,19 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.shell.direnv;
+in
+{
+ options.modules.shell.direnv = {
+ enable = mkEnableOption "enable direnv";
+ };
+ config = mkIf cfg.enable {
+ environment = {
+ # Path to link from packages to /run/current-system/sw
+ pathsToLink = [
+ "/share/nix-direnv"
+ ];
+ systemPackages = [ pkgs.direnv ];
+ };
+ };
+}
systems/modules/shell/git.nix
@@ -0,0 +1,25 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.shell.git;
+in
+{
+ options.modules.shell.git = {
+ enable = mkEnableOption "enable git";
+ };
+ config = mkIf cfg.enable {
+ environment = {
+ # Install some packages
+ systemPackages = with pkgs; [
+ gitAndTools.gitFull
+ gitAndTools.git-annex
+ gitAndTools.git-extras
+ (mkIf config.modules.shell.gnupg.enable
+ gitAndTools.git-crypt)
+ ];
+ # Default gitconfig
+ etc."gitconfig".source = ./git/config;
+ etc."gitignore".source = ./git/ignore;
+ };
+ };
+}
systems/modules/shell/gnupg.nix
@@ -0,0 +1,16 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.shell.gnupg;
+in
+{
+ options.modules.shell.gnupg = {
+ enable = mkEnableOption "enable gnupg";
+ };
+ config = mkIf cfg.enable {
+ environment = {
+ variables.GNUPGHOME = "$XDG_CONFIG_HOME/gnupg";
+ systemPackages = [ pkgs.gnupg ];
+ };
+ };
+}
systems/modules/shell/tmux.nix
@@ -0,0 +1,18 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.shell.tmux;
+in
+{
+ options.modules.shell.tmux = {
+ enable = mkEnableOption "enable tmux";
+ };
+ config = mkIf cfg.enable {
+ programs.tmux = {
+ enable = true;
+ clock24 = true;
+ escapeTime = 0;
+ terminal = "tmux-256color";
+ };
+ };
+}
systems/modules/shell/zsh.nix
@@ -0,0 +1,16 @@
+{ config, lib, pkgs, ... }:
+let
+ inherit (lib) mkEnableOption mkIf;
+ cfg = config.modules.shell.zsh;
+in
+{
+ options.modules.shell.zsh = {
+ enable = mkEnableOption "enable zsh";
+ };
+ config = mkIf cfg.enable {
+ programs.zsh = {
+ enable = true;
+ enableCompletion = true;
+ };
+ };
+}
systems/modules/default.flake.nix
@@ -2,7 +2,13 @@
{
imports = [
+ ./desktop
+ ./editors
+ ./hardware
./profiles/default.flake.nix
+ ./programs
+ ./services
+ ./shell
./virtualisation
];
}
users/vincent/default.flake.nix
@@ -20,7 +20,8 @@ in
uid = 1000;
description = "Vincent Demeester";
extraGroups = [ "wheel" "input" ]
- ++ optionals config.profiles.desktop.enable [ "audio" "video" "networkmanager" ]
+ ++ optionals config.modules.desktop.enable [ "video" ]
+ ++ optionals config.modules.hardware.audio.enable [ "audio" ]
#++ optionals config.profiles.scanning.enable [ "lp" "scanner" ]
++ optionals config.networking.networkmanager.enable [ "networkmanager" ]
++ optionals config.virtualisation.docker.enable [ "docker" ]
users/vincent/home.nix
@@ -3,6 +3,39 @@ let
inherit (lib) mkIf;
in
{
+ profiles = {
+ desktop = {
+ i3.enable = true;
+ browsers = {
+ default = "firefox";
+ firefox.enable = true;
+ };
+ term = {
+ default = "alacritty";
+ alacritty.enable = true;
+ };
+ };
+ editors = {
+ default = "emacs";
+ emacs.enable = true;
+ vim.enable = true;
+ # vscode.enable = false;
+ };
+ dev = {
+ go.enable = true;
+ python.enable = true;
+ };
+ hardware = {
+ ergodox.enable = true;
+ };
+ shell = {
+ git.enable = true;
+ gnupg.enable = true;
+ direnv.enable = true;
+ tmux.enable = true;
+ zsh.enable = true;
+ };
+ };
home.packages = with pkgs; [ htop ];
xsession.windowManager.i3 = mkIf nixosConfig.profiles.desktop.enable {
package = pkgs.i3-gaps;
flake.nix
@@ -143,7 +143,6 @@
};
};
})
- # FIXME remove flake suffix once migrated
(import ./systems/modules/default.flake.nix)
(import config)
]
@@ -237,7 +236,7 @@
overlays = forEachSystem (system: [
(self.overlay."${system}")
(_: _: import inputs.gitignore-nix { lib = inputs.nixpkgs.lib; })
- inputs.nyxt.overlay
+ #inputs.nyxt.overlay
inputs.emacs.overlay
(import ./nix/overlays/infra.nix)
(import ./nix/overlays/mkSecret.nix)