diff --git a/common/configuration.nix b/common/configuration.nix index 2b93d34..1f42b03 100644 --- a/common/configuration.nix +++ b/common/configuration.nix @@ -3,7 +3,7 @@ { # Enable the OpenSSH daemon services.openssh.enable = true; - services.openssh.settings.PermitRootLogin = "no"; + services.openssh.settings.PermitRootLogin = lib.mkDefault "no"; # Activate nix flakes. nix.settings.experimental-features = [ "nix-command" "flakes" ]; @@ -26,6 +26,7 @@ jnettop iperf3 ncdu + git tig ]; diff --git a/flake.nix b/flake.nix index 2aa3e0f..4c96d68 100644 --- a/flake.nix +++ b/flake.nix @@ -19,5 +19,11 @@ specialArgs = attrs; modules = [ ./mesange/configuration.nix ]; }; + + nixosConfigurations."pinson" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs; + modules = [ ./pinson/configuration.nix ]; + }; }; } diff --git a/pinson/configuration.nix b/pinson/configuration.nix new file mode 100644 index 0000000..0693ffe --- /dev/null +++ b/pinson/configuration.nix @@ -0,0 +1,99 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ../common/configuration.nix + ]; + + # Use the GRUB 2 boot loader. + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/vda"; + + # use the latest kernel compatible with zfs + boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + + # workaround because we are in a vm + boot.zfs.devNodes = "/dev/disk/by-partuuid"; + + # setup automatic snapshots (~short term: retain no more than 1 month) + services.zfs.autoSnapshot = { + enable = true; + frequent = 0; + monthly = 0; + }; + + # automatic scrub, 20th of each month at 3AM + services.zfs.autoScrub = { + enable = true; + interval = "*-*-20 03:00:00"; + }; + + networking.hostName = "pinson"; + # required by zfs + networking.hostId = "8425e349"; + + services.openssh.settings.PasswordAuthentication = false; + services.openssh.settings.PermitRootLogin = "yes"; + + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDiT41LuYEluLxyyWR+zM1cOhcp6cC0DosCi1VivJCv8 armael@teabox" + ]; + + users.users."music" = { + isNormalUser = true; + uid = 1001; + }; + + users.users."macaron" = { + isNormalUser = true; + uid = 1002; + }; + + users.groups = { + music = { + gid = 1001; + members = [ "music" "macaron" ]; + }; + }; + + users.users."macaron".openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHrUE40cFRIcnVI8rtopNlC1BVb58jS27/K2PQq5oZPd armael@macaron.isomorphis.me" + ]; + + environment.systemPackages = with pkgs; [ + zfs + beets + ]; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "23.11"; # Did you read the comment? + +} + diff --git a/pinson/hardware-configuration.nix b/pinson/hardware-configuration.nix new file mode 100644 index 0000000..49976b9 --- /dev/null +++ b/pinson/hardware-configuration.nix @@ -0,0 +1,41 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/200637c3-22c6-4ae1-9715-a89802cfc72c"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/5933-ABB0"; + fsType = "vfat"; + }; + + fileSystems."/piscine/musique" = + { device = "piscine/musique"; + fsType = "zfs"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}