# 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, inputs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix #../../modules/users/main-user.nix ]; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; nix.settings.experimental-features = ["nix-command" "flakes"]; boot.initrd.postDeviceCommands = lib.mkAfter '' # Prepare temporary folder mkdir /btrfs_tmp # Open encrypted partition cryptsetup luksOpen /dev/vda3 crypted # Mount unencrypted partition in temp folder mount /dev/mapper/crypted /btrfs_tmp # Check if root subvolume exists in partition if [[ -e /btrfs_tmp/root ]]; then # If a folder for old roots doesnt exist we create one mkdir -p /btrfs_tmp/old_roots # Get timestamp for naming roots timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S") # Move old root into folder mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp" fi delete_subvolume_recursively() { IFS=$'\n' for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do delete_subvolume_recursively "btrfs_tmp/$i" done btrfs subvolume delete "$1" } # Delete old roots older than 30 days for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do delete_subvolume_recursively "$i" done # Create new root btrfs subvolume create /btrfs_tmp/root umount /btrfs_tmp ''; # Dont nuke all the files. We wanna keep something fileSystems."/persist".neededForBoot = true; environment.persistence."/persist/system" = { hideMounts = true; directories = [ "/etc/nixos" "/var/log" "/var/lib/bluetooth" "/var/lib/nixos" "/var/lib/systemd/coredump" "/etc/NetworkManager/system-connections" { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx, g=rx, o="; } ]; files = [ "/etc/machine-id" "/etc/ssh/ssh_host_rsa_key" "/etc/ssh/ssh_host_ed25519_key" "/etc/ssh/ssh_host_rsa_key.pub" "/etc/ssh/ssh_host_ed25519_key.pub" ]; }; programs.fuse.userAllowOther = true; home-manager = { extraSpecialArgs = {inherit inputs;}; users = { "snorre" = import ./home.nix; }; }; users.users."snorre" = { isNormalUser = true; initialPassword = "1234"; extraGroups = [ "networkmanager" "audio" "wheel" ]; shell = pkgs.zsh; }; # Programs to enable programs.zsh.enable = true; # Better shell than bash # Fuck nano, all my homies hate nano programs.nano.enable = false; # Delete old entries to nix = { gc = { automatic = true; options = "--delete-older-than 7d"; }; }; stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/eighties.yaml"; stylix.autoEnable = true; stylix.polarity = "dark"; stylix.cursor.package = pkgs.bibata-cursors; stylix.cursor.name = "Bibata-Modern-Ice"; stylix.cursor.size = 24; networking.hostName = "nixos-vm"; # Define your hostname. networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. # Set your time zone. time.timeZone = "Europe/Copenhagen"; # Select internationalisation properties. i18n.defaultLocale = "en_US.UTF-8"; console = { keyMap = "dk"; }; # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ wget curl git neovim ]; # Remove message when running commands as sudo security.sudo = { enable = true; extraConfig = '' Defaults lecture = never ''; }; services.openssh = { enable = true; settings = { PasswordAuthentication = true; AllowUsers = null; PermitRootLogin = "no"; }; }; # 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? }