-{ config, pkgs, lib, private, hostName, ... }:
+{ config, pkgs, lib, inputs, hostName, ... }:
{
-imports = [
- ../nixos/profiles/dnscrypt-proxy2.nix
- ../nixos/profiles/security.nix
- ../nixos/profiles/wireguard/wg-intra.nix
- oignon/hardware.nix
- oignon/wireguard.nix
- oignon/tor.nix
- oignon/backup.nix
-];
-
-home-manager.users.julm = {
- imports = [ ../homes/julm.nix ];
- host.hardware = [ "ThinkPad" "X201" ];
-};
-systemd.services.home-manager-julm.postStart = ''
- ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/julm/home-manager
-'';
-security.lockKernelModules = false;
-users.mutableUsers = false;
-users.users.julm = {
- isNormalUser = true;
- uid = 1000;
- # Put the hashedPassword in /nix/store, but it will also be in /etc/passwd
- # which is already world readable.
- hashedPassword = lib.readFile ../private/world/julm/hashedPassword;
- extraGroups = [
- "adbusers"
- "lp"
- "networkmanager"
- "scanner"
- "tor"
- "video"
- "wheel"
- #"ipfs"
- config.services.davfs2.davGroup
- #"vboxusers"
+ imports = [
+ ../nixos/profiles/builder.nix
+ ../nixos/profiles/debug.nix
+ ../nixos/profiles/graphical.nix
+ ../nixos/profiles/irssi.nix
+ ../nixos/profiles/lang-fr.nix
+ ../nixos/profiles/printing.nix
+ ../nixos/profiles/radio.nix
+ ../nixos/profiles/tor.nix
+ oignon/backup.nix
+ oignon/hardware.nix
+ oignon/networking.nix
];
- # If created, zfs-mount.service would require:
- # zfs set overlay=yes ${hostName}/home
- createHome = false;
-};
-
-nix = {
- extraOptions = ''
- secret-key-files = ${private}/${hostName}/nix/binary-cache/priv.pem
- '';
- autoOptimiseStore = true;
- gc.automatic = true;
- gc.dates = "weekly";
- gc.options = "--delete-older-than 7d";
- nixPath = lib.mkForce [];
- trustedUsers = [ config.users.users.julm.name ];
- binaryCaches = [ "http://nix-localcache.losurdo.wg" ];
- binaryCachePublicKeys = [ "losurdo.sourcephile.fr-1:XGeaIE2AA2mZskSZ5bIDrfx53q+TDDWJOUEpZDX7los=" ];
-};
-#environment.etc."nixpkgs".source = pkgs.path;
-#environment.etc."nixpkgs-overlays".source = inputs.self + "/nixpkgs";
-documentation = {
- enable = true;
- dev.enable = true;
- doc.enable = true;
- info.enable = false;
- man.enable = true;
- nixos.enable = false;
-};
-nix.sshServe = {
- enable = true;
- keys = [ (lib.readFile ../private/world/julm/losurdo/ssh.pub) ];
-};
-users.users.julm.openssh.authorizedKeys.keys = [
- (lib.readFile ../private/world/julm/losurdo/ssh.pub)
-];
+ # Lower kernel's security for better performances
+ boot.kernelParams = [ "mitigations=off" ];
-time.timeZone = "Europe/Paris";
-i18n.defaultLocale = "fr_FR.UTF-8";
-console.font = "Lat2-Terminus16";
-console.keyMap = "fr";
+ home-manager.users.julm = {
+ imports = [ ../homes/julm.nix ];
+ };
+ users.users.root = {
+ openssh.authorizedKeys.keys = map lib.readFile [
+ # For nix -L run .#oignon.switch
+ ../users/julm/ssh/oignon.pub
+ ];
+ };
+ users.users.julm = {
+ isNormalUser = true;
+ uid = 1000;
+ # Put the hashedPassword in /nix/store,
+ # though /etc/shadow is not world readable...
+ # printf %s $(mkpasswd -m md5crypt)
+ hashedPassword = lib.readFile oignon/users/julm/login/hashedPassword.clear;
+ extraGroups = [
+ "adbusers"
+ "dialout"
+ "lp"
+ "networkmanager"
+ "plugdev" # For rtl-sdr
+ "scanner"
+ "tor"
+ "video"
+ "wheel"
+ #"ipfs"
+ config.services.davfs2.davGroup
+ #"vboxusers"
+ ];
+ # If created, zfs-mount.service would require:
+ # zfs set overlay=yes ${hostName}/home
+ createHome = false;
+ openssh.authorizedKeys.keys = map lib.readFile [
+ ../users/julm/ssh/losurdo.pub
+ ];
+ };
-networking = {
- hostName = hostName;
- domain = "localdomain";
- search = [ "sourcephile.fr" ];
- networkmanager = {
- enable = true;
- #dhcp = "dhcpcd";
- logLevel = "INFO";
- wifi = {
- #backend = "iwd";
- #backend = "wpa_supplicant";
- powersave = false;
+ systemd.services.nix-daemon.serviceConfig.LoadCredentialEncrypted =
+ [ ("${hostName}.key:${inputs.self}/hosts/${hostName}/nix/secret-key-files.priv.pem.cred") ];
+ nix = {
+ extraOptions = ''
+ secret-key-files = /run/credentials/nix-daemon.service/${hostName}.key
+ '';
+ settings = {
+ substituters = [
+ #"http://nix-localcache.losurdo.wg"
+ "ssh://nix-ssh@losurdo.wg?priority=30"
+ ];
+ trusted-public-keys = map lib.readFile [
+ ../users/nix/ssh/losurdo.pub
+ ];
};
+ nixPath = lib.mkForce [ "nixpkgs=${inputs.nixpkgs}" ];
};
- firewall = {
+ #environment.etc."nixpkgs".source = pkgs.path;
+ #environment.etc."nixpkgs-overlays".source = inputs.self + "/nixpkgs";
+
+ nix.settings.allowed-users = [ config.users.users."nix-ssh".name ];
+ nix.sshServe = {
enable = true;
- allowPing = true;
+ keys = map lib.readFile [
+ ../users/julm/ssh/losurdo.pub
+ ../users/julm/ssh/oignon.pub
+ ../users/sevy/ssh/patate.pub
+ ];
};
-};
-sound.enable = true;
-hardware.pulseaudio.enable = true;
-hardware.sane.enable = true;
-hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];
+ environment.systemPackages = [
+ pkgs.riseup-vpn # Can't be installed by home-manager because it needs to install policy-kit rules
+ ];
-environment.variables = {
- EDITOR = "vim";
- PAGER = "less -R";
- SYSTEMD_LESS = "FKMRX";
-};
+ boot.extraModulePackages = [
+ #config.boot.kernelPackages.v4l2loopback
+ ];
-programs.bash.interactiveShellInit = ''
- fan () {
- if [ $# -gt 0 ]
- then sudo tee /proc/acpi/ibm/fan <<<"level $1"
- else grep '^\(level\|speed\):' /proc/acpi/ibm/fan
- fi
- acpi -t
- }
-'';
-programs.dconf.enable = true;
-programs.mtr.enable = true;
+ programs.fuse.userAllowOther = true;
-services.avahi = {
- enable = true;
- nssmdns = true;
- openFirewall = false;
- publish = {
- enable = false;
- };
-};
-services.davfs2.enable = true;
-fileSystems."/home/julm/mnt/ilico/severine" = {
- device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
- fsType = "davfs";
- options =
- let conf = pkgs.writeText "davfs2.conf" ''
- backup_dir /home/julm/documents/backup/ilico/severine
- cache_dir /home/julm/.cache/davfs2/ilico/severine
- ''; in
- [ "conf=${conf}" "user" "noexec" "nosuid" "noauto" ]; # "x-systemd.automount"
-};
-programs.fuse.userAllowOther = true;
-fileSystems."/mnt/losurdo" = {
- device = "${pkgs.sshfsFuse}/bin/sshfs#julm@losurdo.wg:/";
- fsType = "fuse";
- options =
- # Use the user's gpg-agent session to query
- # for the password of the SSH key when auto-mounting.
- let sshAsUser = user:
- pkgs.writeScript "sshAsUser-${user}" ''
- exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
- ${pkgs.openssh}/bin/ssh "$@"
- '';
- in [
- "noatime" "noexec" "nosuid"
- "user" "uid=julm" "gid=users" "allow_other"
- "_netdev" "reconnect" "ssh_command=${sshAsUser "julm"}"
- "noauto" "x-gvfs-hide" "x-systemd.automount"
- "Cipher=arcfour" # No need for encryption over Wireguard
- #"Compression=yes" # YMMV
- # Disconnect approximately 2*15=30 seconds after a network failure
- "ServerAliveCountMax=2"
- "ServerAliveInterval=15"
- ];
-};
-services.dbus = {
- packages = [ pkgs.gnome3.dconf ];
-};
-services.gvfs.enable = true;
-services.ipfs = {
- #enable = true;
- defaultMode = "online";
- autoMount = true;
- enableGC = true;
- localDiscovery = false;
- extraConfig = {
- Datastore.StorageMax = "10GB";
- Discovery.MDNS.Enabled = false;
- #Bootstrap = [
- #];
- #Swarm.AddrFilters = null;
- };
- startWhenNeeded = true;
-};
-services.openssh = {
- forwardX11 = true;
-};
-services.printing = {
- enable = true;
- drivers = [
- pkgs.gutenprint
- pkgs.hplip
+ services.davfs2.enable = true;
+
+ systemd.automounts = [
+ { where = "/mnt/aubergine"; automountConfig.TimeoutIdleSec = "5 min"; }
];
-};
-services.udev = {
- packages = [
- # Allow members of the "adbusers" group to mount Android devices via MTP.
- pkgs.android-udev-rules
+ fileSystems =
+ let
+ # Use the user's gpg-agent session to query
+ # for the password of the SSH key when auto-mounting.
+ sshAsUser =
+ pkgs.writeScript "sshAsUser" ''
+ user="$1"; shift
+ exec ${pkgs.sudo}/bin/sudo -i -u "$user" \
+ ${pkgs.openssh}/bin/ssh "$@"
+ '';
+ options =
+ [
+ "user"
+ "uid=julm"
+ "gid=users"
+ "allow_other"
+ "exec" # Override "user"'s noexec
+ "noatime"
+ "nosuid"
+ "_netdev"
+ "ssh_command=${sshAsUser}\\040julm"
+ "noauto"
+ "x-gvfs-hide"
+ "x-systemd.automount"
+ #"Compression=yes" # YMMV
+ # Disconnect approximately 2*15=30 seconds after a network failure
+ "ServerAliveCountMax=1"
+ "ServerAliveInterval=15"
+ "dir_cache=no"
+ #"reconnect"
+ ];
+ in
+ {
+ "/mnt/aubergine" = {
+ device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@aubergine.wg:/";
+ fsType = "fuse";
+ inherit options;
+ };
+ "/mnt/losurdo" = {
+ device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.wg:/";
+ fsType = "fuse";
+ inherit options;
+ };
+ "/mnt/mermet" = {
+ device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.wg:/";
+ fsType = "fuse";
+ inherit options;
+ };
+ "/mnt/ilico/severine" = {
+ device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
+ fsType = "davfs";
+ options =
+ let
+ conf = pkgs.writeText "davfs2.conf" ''
+ backup_dir /home/julm/.local/share/davfs2/ilico/severine
+ secrets /home/julm/.davfs2/secrets
+ '';
+ in
+ [
+ "conf=${conf}"
+ "user"
+ "noexec"
+ "nosuid"
+ "noauto"
+ "nofail"
+ "_netdev"
+ "reconnect"
+ "x-systemd.automount"
+ "x-systemd.device-timeout=1m"
+ "x-systemd.idle-timeout=1m"
+ "x-systemd.mount-timeout=10s"
+ ];
+ };
+ };
+
+ networking.firewall.extraCommands = ''
+ ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
+ '';
+
+ services.kubo = {
+ #enable = true;
+ defaultMode = "online";
+ autoMount = true;
+ enableGC = true;
+ localDiscovery = false;
+ settings = {
+ Datastore.StorageMax = "10GB";
+ Discovery.MDNS.Enabled = false;
+ #Bootstrap = [
+ #];
+ #Swarm.AddrFilters = null;
+ };
+ startWhenNeeded = true;
+ };
+
+ services.udev.packages = [
# Allow the console user access the Yubikey USB device node,
# needed for challenge/response to work correctly.
pkgs.yubikey-personalization
];
-};
-services.xserver = {
- enable = true;
- layout = "fr";
- xkbOptions = "eurosign:e";
- libinput.enable = true;
- desktopManager = {
- session = [
- # Let the session be generated by home-manager
- { name = "home-manager";
- start = ''
- ${pkgs.runtimeShell} $HOME/.hm-xsession &
- waitPID=$!
- '';
- }
- ];
- };
- displayManager = {
- defaultSession = "home-manager";
- #defaultSession = "none+xmonad";
- autoLogin = {
- enable = true;
- user = config.users.users.julm.name;
+
+ services.xserver = {
+ layout = "fr,us(altgr-intl)";
+ desktopManager = {
+ session = [
+ # Let the session be generated by home-manager
+ {
+ name = "home-manager";
+ start = ''
+ ${pkgs.runtimeShell} $HOME/.hm-xsession &
+ waitPID=$!
+ '';
+ }
+ ];
+ };
+ displayManager = {
+ defaultSession = "home-manager";
+ #defaultSession = "none+xmonad";
+ #defaultSession = "mate";
+ #defaultSession = "cinnamon";
+ autoLogin = {
+ user = config.users.users.julm.name;
+ };
};
};
-};
-
-systemd.coredump.enable = true;
-#environment.enableDebugInfo = true;
-# This value determines the NixOS release with which your system is to be
-# compatible, in order to avoid breaking some software such as database
-# servers. You should change this only after NixOS release notes say you should.
-system.stateVersion = "20.09"; # Did you read the comment?
+ # This value determines the NixOS release with which your system is to be
+ # compatible, in order to avoid breaking some software such as database
+ # servers. You should change this only after NixOS release notes say you should.
+ system.stateVersion = "20.09"; # Did you read the comment?
}