From be5341b5b11f2ca43315b82459b18c486aacb917 Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sat, 21 Dec 2024 09:49:20 -0700 Subject: [PATCH] Disable home impermanence --- .gitignore | 10 - README.org | 218 +------------------- flake.lock | 159 +++++++++++++- flake.nix | 130 ++++++++++++ hosts/nixos-testbed/configuration.nix | 103 +++++++++ modules/home/impermanence.nix | 54 ++++- modules/nixos/erase-home-darlings.clj | 28 ++- modules/nixos/impermanence.nix | 70 +++++-- modules/nixos/niri.nix | 51 +++++ users/crumb/default.nix | 30 ++- users/crumb/dots/nvim/.config/nvim/init.vim | 1 + users/crumb/dots/nvim/.vimrc | 2 + 12 files changed, 594 insertions(+), 262 deletions(-) create mode 100644 flake.nix create mode 100644 hosts/nixos-testbed/configuration.nix create mode 100644 modules/nixos/niri.nix create mode 100644 users/crumb/dots/nvim/.config/nvim/init.vim create mode 100644 users/crumb/dots/nvim/.vimrc diff --git a/.gitignore b/.gitignore index 1364a37..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +0,0 @@ -# A list of files generated from README.org can be gathered and inserted by -# evaluating the following snippet: -# (mapc (lambda (target) -# (insert (concat (file-relative-name target) -# "\n"))) -# (org-babel-tangle-file "README.org")) - -hosts/nixos-testbed/configuration.nix -modules/system/impermanence.nix -flake.nix diff --git a/README.org b/README.org index 35083df..d4225c6 100644 --- a/README.org +++ b/README.org @@ -1,225 +1,11 @@ #+PROPERTY: header-args :noweb no-export :results silent :comments both :tangle no #+STARTUP: overview -#+title: Madeleine's dots for the literate (=sydnix=) - -* Top-level flake - -#+begin_src nix :tangle flake.nix -{ - description = "Madeleine's dots for the literate (sydnix)"; - - inputs = { - <> - - disko.url = "github:nix-community/disko"; - - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - impermanence.url = "github:nix-community/impermanence"; - - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { nixpkgs, ... }@inputs: - let list-nix-directory = dir: - builtins.attrNames - (nixpkgs.lib.filterAttrs - (k: _v: nixpkgs.lib.hasSuffix ".nix" k) - (builtins.readDir dir)); - in { - # REVIEW: Why don't we put each module under nixosModules.? - nixosModules.default = - let modules = list-nix-directory ./modules/nixos; - in { ... }: { - imports = - builtins.map (m: ./modules/nixos/${m}) modules; - }; - - homeManagerModules.default = - let modules = list-nix-directory ./modules/home; - in { ... }: { - imports = - builtins.map (m: ./modules/home/${m}) modules; - }; - - nixosConfigurations = ( - <> - ); - - homeConfigurations = - let users = builtins.readDir ./users; - mkUser = username: _v: { - imports = [ - (import ./users/${username}).home - - inputs.self.homeManagerModules.default - - ({ lib, ... }: { - home.username = username; - }) - - inputs.impermanence.homeManagerModules.impermanence - ]; - }; - in - builtins.mapAttrs mkUser users; - }; -} -#+end_src - -* Machines - -For every ~./hosts/NAME/configuration.nix~, define the system under the name ~NAME~. - -#+begin_src nix :noweb-ref flake-outputs-nixos -let mkHost = k: v: nixpkgs.lib.nixosSystem { - specialArgs = inputs; - system = import ./hosts/${k}/system.nix; - modules = [ - ./hosts/${k}/configuration.nix - - inputs.self.nixosModules.default - - inputs.disko.nixosModules.disko - inputs.impermanence.nixosModules.impermanence - - # Directory name should always match host name. - ({ ... }: { networking.hostName = k; }) - - # home-manager configuration. - inputs.home-manager.nixosModules.home-manager - ({ config, lib, self, ... }: { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - home-manager.users = - lib.filterAttrs - (k: _v: builtins.elem k config.sydnix.users.users) - self.homeConfigurations; - - home-manager.extraSpecialArgs = inputs // { inherit self; }; - }) - ]; - }; -in -builtins.mapAttrs mkHost (builtins.readDir ./hosts) -#+end_src - -** =nixos-testbed= - -#+begin_src nix :tangle hosts/nixos-testbed/configuration.nix -{ config, pkgs, lib, disko, ... }: -{ - imports = [ - ./hardware-configuration.nix - ./disko-config.nix - ]; - - sydnix = { - impermanence = { - enable = true; - directories = [ - # Warning: Neither /var/lib/nixos nor any of its parents are persisted. - # This means all users/groups without specified uids/gids will have them - # reassigned on reboot. - "/var/lib/nixos" - ]; - rollbackTo = "blank"; - dataset = "rpool/local/home"; - archiveLimit = 3; - }; - users.users = [ - "crumb" - ]; - }; - - boot = { - initrd = { - enable = true; - systemd.enable = true; - - systemd.initrdBin = with pkgs; [ - zfs - coreutils - babashka - ]; - }; - - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = false; - }; - }; - - # networking.hostName = "nixos-testbed"; - networking.hostId = "238e9b1e"; # head -c 8 /etc/machine-id - - time.timeZone = "America/Denver"; - - i18n.defaultLocale = "en_US.UTF-8"; - - console = { - font = "Lat2-Terminus16"; - # keyMap = "us"; - useXkbConfig = true; # use xkb.options in tty. - }; - - services.xserver.enable = true; - # services.displayManager.sddm.enable = true; - # services.desktopManager.plasma6.enable = true; - - services.xserver.xkb.layout = "us"; - services.xserver.xkb.options = "caps:escape"; - - users.users.crumb = { - isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - # Change this immediately after installation! - initialPassword = "password123"; - }; - - environment.systemPackages = with pkgs; [ - neovim - ]; - - services.openssh.enable = true; - services.openssh.settings.PermitRootLogin = "yes"; - - # 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 - see - # https://nixos.org/manual/nixos/stable/#sec-upgrading for how to actually do - # that. - # - # 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 = "24.05"; # Did you read the comment? -} -#+end_src - -** =guix-rebound= - -The primary desktop of a girl done with her plebian phase, and done with Guix's -bullshit. +#+title: Madeleine's nest (=sydnix=) * References - My darling dearest Faye's =wishsys= }:D - [[https://github.com/rasendubi/dotfiles][rasendubi/dotfiles]] +- [[https://git.mangoiv.com/mangoiv/dotfiles][magoiv/dotfiles]] - [[https://github.com/hlissner/dotfiles/][hlissner/dotfiles]] - [[https://github.com/Shawn8901/nix-configuration/tree/af71d51998a6772a300f842795b947e27202fa73][Shawn8901/nix-configuration]] diff --git a/flake.lock b/flake.lock index f9e4cac..32b9a29 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1734088167, + "narHash": "sha256-OIitVU+IstPbX/NWn2jLF+/sT9dVKcO2FKeRAzlyX6c=", + "owner": "nix-community", + "repo": "disko", + "rev": "d32f2d1750d61a476a236526b725ec5a32e16342", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -35,7 +53,111 @@ "type": "github" } }, + "niri": { + "inputs": { + "niri-stable": "niri-stable", + "niri-unstable": "niri-unstable", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable", + "xwayland-satellite-stable": "xwayland-satellite-stable", + "xwayland-satellite-unstable": "xwayland-satellite-unstable" + }, + "locked": { + "lastModified": 1734280237, + "narHash": "sha256-+dtkltYnfqR8R78YGkzn/kBn3sRAQEN5L7PWP0A0x/U=", + "owner": "sodiboo", + "repo": "niri-flake", + "rev": "8d87a092be1823ab5a9dfb9c94cc98d151302a6a", + "type": "github" + }, + "original": { + "owner": "sodiboo", + "repo": "niri-flake", + "type": "github" + } + }, + "niri-stable": { + "flake": false, + "locked": { + "lastModified": 1731483594, + "narHash": "sha256-Qjf7alRbPPERfiZsM9EMKX+HwjESky1tieh5PJIkLwE=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "75c79116a7e40cbc0e110ce0cdd500e896458679", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v0.1.10.1", + "repo": "niri", + "type": "github" + } + }, + "niri-unstable": { + "flake": false, + "locked": { + "lastModified": 1734270275, + "narHash": "sha256-FfpxEVDPQ1qSDoLOqnSK2laM6oPklgZhd2YWzxOB8Ns=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "d35ad73e3572b0ac704b0c08928f53d0cfd1951f", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "repo": "niri", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1733749988, + "narHash": "sha256-+5qdtgXceqhK5ZR1YbP1fAUsweBIrhL38726oIEAtDs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bc27f0fde01ce4e1bfec1ab122d72b7380278e68", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1734017764, + "narHash": "sha256-msOfmyJSjAHgIygI/JD0Ae3JsDv4rT54Nlfr5t6MQMQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "64e9404f308e0f0a0d8cdd7c358f74e34802494b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1731245184, "narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=", @@ -53,9 +175,44 @@ }, "root": { "inputs": { + "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", - "nixpkgs": "nixpkgs" + "niri": "niri", + "nixpkgs": "nixpkgs_3" + } + }, + "xwayland-satellite-stable": { + "flake": false, + "locked": { + "lastModified": 1730166465, + "narHash": "sha256-nq7bouXQXaaPPo/E+Jbq+wNHnatD4dY8OxSrRqzvy6s=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "a713cf46cb7db84a0d1b57c3a397c610cad3cf98", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "ref": "v0.5", + "repo": "xwayland-satellite", + "type": "github" + } + }, + "xwayland-satellite-unstable": { + "flake": false, + "locked": { + "lastModified": 1734112800, + "narHash": "sha256-9qSb6AJpmzV3oYRfsyEt0e9eju6UeXDSD1poeSwadKo=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "c45c2ed990912c26e6aed0f47bfddb03993d7999", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..33a9a13 --- /dev/null +++ b/flake.nix @@ -0,0 +1,130 @@ +{ + description = "Madeleine's dots for the illiterate (sydnix)"; + + inputs = { + disko.url = "github:nix-community/disko"; + + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + impermanence.url = "github:nix-community/impermanence"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + niri.url = "github:sodiboo/niri-flake"; + }; + + outputs = { nixpkgs, ... }@inputs: + let list-nix-directory = dir: + builtins.attrNames + (nixpkgs.lib.filterAttrs + (k: _v: nixpkgs.lib.hasSuffix ".nix" k) + (builtins.readDir dir)); + in { + # REVIEW: Why don't we put each module under nixosModules.? + nixosModules.default = + let modules = list-nix-directory ./modules/nixos; + in { ... }: { + imports = + builtins.map (m: ./modules/nixos/${m}) modules; + }; + + homeManagerModules.default = + let modules = list-nix-directory ./modules/home; + in { ... }: { + imports = + builtins.map (m: ./modules/home/${m}) modules; + }; + + nixosConfigurations = ( + let mkHost = k: v: nixpkgs.lib.nixosSystem { + specialArgs = inputs; + system = import ./hosts/${k}/system.nix; + # TODO: This is very ad-hoc, and I don't like it. Organise this better. + modules = [ + ./hosts/${k}/configuration.nix + + inputs.self.nixosModules.default + + inputs.disko.nixosModules.disko + inputs.impermanence.nixosModules.impermanence + + # Directory name should always match host name. + ({ ... }: { networking.hostName = k; }) + + # Get system users + ({ config, lib, ... }: { + users.users = + (lib.mapAttrs + (k: v: (import ./users/${k}).systemUser) + (lib.filterAttrs + (k: _v: builtins.elem k config.sydnix.users.users) + (builtins.readDir ./users))); + }) + + # Nixpkgs configuration + ({ pkgs, ... }: { + nixpkgs.config.allowUnfree = true; + + documentation = { + man.enable = true; + info.enable = true; + }; + + environment.systemPackages = with pkgs; [ + man-pages + stdman + man-pages-posix + stdmanpages + ]; + }) + + # home-manager configuration. + inputs.home-manager.nixosModules.home-manager + ({ config, lib, self, ... }: { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.users = + lib.filterAttrs + (k: _v: builtins.elem k config.sydnix.users.users) + self.homeConfigurations; + + home-manager.extraSpecialArgs = inputs // { inherit self; }; + }) + ]; + }; + in + builtins.mapAttrs mkHost (builtins.readDir ./hosts) + ); + + homeConfigurations = + let users = builtins.readDir ./users; + mkUser = username: _v: { + # TODO: This is very ad-hoc, and I don't like it. Organise this better. + imports = [ + (import ./users/${username}).home + + inputs.self.homeManagerModules.default + + ({ lib, ... }: { + home.username = username; + }) + + ({ pkgs, lib, ... }: { + nix = { + settings.experimental-features = + lib.mkDefault + [ "nix-command" "flakes" ]; + }; + }) + + inputs.impermanence.homeManagerModules.impermanence + ]; + }; + in + builtins.mapAttrs mkUser users; + }; +} diff --git a/hosts/nixos-testbed/configuration.nix b/hosts/nixos-testbed/configuration.nix new file mode 100644 index 0000000..d16bcba --- /dev/null +++ b/hosts/nixos-testbed/configuration.nix @@ -0,0 +1,103 @@ +{ config, pkgs, lib, disko, ... }: +{ + imports = [ + ./hardware-configuration.nix + ./disko-config.nix + ]; + + sydnix = { + impermanence = { + enable = true; + directories = [ + # Warning: Neither /var/lib/nixos nor any of its parents are persisted. + # This means all users/groups without specified uids/gids will have them + # reassigned on reboot. + "/var/lib/nixos" + "/etc/ssh" + ]; + rollbackTo = "blank"; + dataset = "rpool/local/home"; + archiveLimit = 3; + }; + users.users = [ + "crumb" + ]; + # niri.enable = true; + }; + + boot = { + initrd = { + enable = true; + systemd.enable = true; + + systemd.initrdBin = with pkgs; [ + zfs + coreutils + babashka + ]; + }; + + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = false; + }; + }; + + # networking.hostName = "nixos-testbed"; + networking.hostId = "238e9b1e"; # head -c 8 /etc/machine-id + + time.timeZone = "America/Denver"; + + i18n.defaultLocale = "en_US.UTF-8"; + + console = { + font = "Lat2-Terminus16"; + # keyMap = "us"; + useXkbConfig = true; # use xkb.options in tty. + }; + + services.xserver.enable = true; + services.displayManager.sddm.enable = true; + services.desktopManager.plasma6.enable = true; + + services.xserver.xkb.layout = "us"; + services.xserver.xkb.options = "caps:escape"; + + environment.systemPackages = with pkgs; [ + neovim + git + ]; + + services.openssh.enable = true; + services.openssh.settings.PermitRootLogin = "yes"; + + # services.xserver.windowManager.qtile = { + # enable = true; + # extraPackages = python3Packages: with python3Packages; [ + # qtile-extras + # hy + # ]; + # }; + + # 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 - see + # https://nixos.org/manual/nixos/stable/#sec-upgrading for how to actually do + # that. + # + # 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 = "24.05"; # Did you read the comment? +} diff --git a/modules/home/impermanence.nix b/modules/home/impermanence.nix index 5e52dc9..af0a8c1 100644 --- a/modules/home/impermanence.nix +++ b/modules/home/impermanence.nix @@ -7,10 +7,34 @@ let in { options = { sydnix.impermanence = { - enable = mkOption { - description = "Enable Impermanence"; - type = types.bool; - default = false; + enable = mkEnableOption "impermanence"; + + mutableDotfiles = { + enable = mkEnableOption "dotfiles under impermanence"; + + # storeAt = mkOption { + # default = "dots/config"; + # type = types.str; + # # type = with types; + # # addCheck + # # path + # # (x: cfg.mutableDotfiles.enable + # # -> ! (elem x cfg.mutableDotfiles.directories)); + # }; + + files = mkOption { + default = []; + # FIXME: Inaccurate type. + type = with types; + listOf anything; + }; + + directories = mkOption { + default = []; + # FIXME: Inaccurate type. + type = with types; + listOf anything; + }; }; directories = mkOption { @@ -28,10 +52,22 @@ in { }; config = mkIf cfg.enable { - home.persistence."/persist/home/${config.home.username}" = { - allowOther = true; - directories = cfg.directories; - files = cfg.files; - }; + home.persistence = { + "/persist/home/${config.home.username}" = { + allowOther = true; + directories = cfg.directories; + files = cfg.files; + }; + } // (if ! cfg.mutableDotfiles.enable + then {} + else { + "/persist/dots/users/${config.home.username}/dots/" = { + removePrefixDirectory = true; + directories = cfg.mutableDotfiles.directories; + files = cfg.mutableDotfiles.files; + allowOther = true; + }; + }); + }; } diff --git a/modules/nixos/erase-home-darlings.clj b/modules/nixos/erase-home-darlings.clj index f2e8052..8da6f17 100644 --- a/modules/nixos/erase-home-darlings.clj +++ b/modules/nixos/erase-home-darlings.clj @@ -1,17 +1,19 @@ #!/usr/bin/env bb -;;; TODO: rewrite with fewer assumptions about the filesystem structure. +;; TODO: rewrite with fewer assumptions about the filesystem structure. Perhaps +;; we can achieve near-atomicity by doing to bulk of the work with a function +;; `erase-home-darlings : FileSystem -> Maybe FileSystem`, which will not do any +;; IO. -;;; TODO: option to either move OR copy +;; TODO: option to either move OR copy (require '[clojure.core.match :refer [match]] '[babashka.cli :as cli] '[clojure.pprint :as pp] + '[clojure.tools.logging :as l] '[babashka.process :refer [shell check process] :as p]) (defn get-files [{:keys [rollback-to dataset]}] - ;; (prn rollback-to) - ;; (prn dataset) (let [snapshot (str dataset "@" rollback-to) diff (:out (shell {:out :string} "zfs diff -HF" @@ -139,9 +141,27 @@ More precisely, (defn -main [opts] (pp/pprint opts) (with-echoed-shell-commands + (shell "mount" (:dataset opts) "/home") (let [files (get-files opts)] (archive-files opts files) (cycle-archives opts) (do-rollback opts)))) +#_ +(def fs-ops + {:zfs {:get-files zfs-get-files + :rollback zfs-rollback}}) + +#_ +(defn -main [opts] + (let [test-bin (fn [x] + (printf "%s: %s\n" + x (map str (fs/which-all x))))] + (test-bin "mount") + (test-bin "findmnt") + (test-bin "zfs")) + + (shell "mount") + (shell "ls -la /home")) + (-main (cli/parse-opts *command-line-args* cli-spec)) diff --git a/modules/nixos/impermanence.nix b/modules/nixos/impermanence.nix index 3f6299e..4f31ae3 100644 --- a/modules/nixos/impermanence.nix +++ b/modules/nixos/impermanence.nix @@ -20,6 +20,11 @@ in { default = []; }; + persistGroupName = mkOption { + default = "persist"; + type = types.str; + }; + files = mkOption { description = ""; @@ -45,10 +50,28 @@ in { }; config = mkIf cfg.enable { + users.groups.${cfg.persistGroupName} = { + name = cfg.persistGroupName; + }; + + systemd.tmpfiles.settings = { + "10-persist" = { + "/persist" = { + z = { + group = cfg.persistGroupName; + mode = "2775"; + }; + }; + }; + }; + boot.initrd.systemd.initrdBin = with pkgs; [ zfs ]; + # TODO: Move this somewhere else. + programs.fuse.userAllowOther = true; + boot.initrd.systemd.services.erase-darlings = let service = { description = "Rollback filesystem to a blank state on boot"; @@ -77,28 +100,35 @@ in { then service else throw "sydnix.impermanence currently requires config.boot.initrd.systemd.enable'!"; - systemd.services.erase-home-darlings = { - description = "Rollback home to a blank state on boot"; - wantedBy = [ - "multi-user.target" - ]; - after = [ - "home.mount" - ]; - path = [ pkgs.zfs pkgs.babashka ]; - # unitConfig.DefaultDependencies = "no"; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStart = - let script = ./erase-home-darlings.clj; - in ''${pkgs.babashka}/bin/bb "${script}" -n "${toString cfg.archiveLimit}" --dataset "${cfg.dataset}" --rollback-to "${cfg.rollbackTo}"''; + systemd.services = + let erase-home-darlings = { + description = "Rollback home to a blank state on boot"; + wantedBy = [ + "local-fs-pre.target" + "zfs-mount.service" + ]; + before = [ + "local-fs.target" + "local-fs-pre.target" + "zfs-mount.service" + ]; + path = [ pkgs.zfs pkgs.babashka pkgs.util-linux ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = + let script = ./erase-home-darlings.clj; + in ''${pkgs.babashka}/bin/bb "${script}" -n "${toString cfg.archiveLimit}" --dataset "${cfg.dataset}" --rollback-to "${cfg.rollbackTo}"''; + }; + stopIfChanged = false; + restartIfChanged = false; + }; + in { + # inherit erase-home-darlings; }; - stopIfChanged = false; - restartIfChanged = false; - }; - environment.persistence."/persist" = { + environment.persistence."/persist/root" = { directories = cfg.directories; files = cfg.files; }; diff --git a/modules/nixos/niri.nix b/modules/nixos/niri.nix new file mode 100644 index 0000000..a22877a --- /dev/null +++ b/modules/nixos/niri.nix @@ -0,0 +1,51 @@ +{ config, lib, pkgs, niri, ... }: + +with lib; + +let + cfg = config.sydnix.niri; +in { + options = { + sydnix.niri = { + enable = mkEnableOption "Niri"; + }; + }; + + imports = [ + niri.nixosModules.niri + ]; + + config = mkIf cfg.enable { + + programs.niri = { + enable = true; + }; + + services.pipewire.enable = true; + + # programs.niri.enable = true; + + # hardware = { + # graphics = { + # enable = true; + # extraPackages = with pkgs; [ + # intel-media-sdk + # mesa + # ]; + # enable32Bit = true; + # }; + # nvidia = { + # open = false; + # modesetting.enable = true; + # }; + # }; + + # environment.systemPackages = with pkgs; [ + # fuzzel + # ]; + + # services.xserver.videoDrivers = [ "qxl" "nvidia" ]; + # services.qemuGuest.enable = true; + # services.spice-vdagentd.enable = true; + }; +} diff --git a/users/crumb/default.nix b/users/crumb/default.nix index 398c90a..05dd682 100644 --- a/users/crumb/default.nix +++ b/users/crumb/default.nix @@ -1,12 +1,38 @@ { + systemUser = { + isNormalUser = true; + extraGroups = [ "wheel" "persist" ]; + # Change this immediately after installation! + initialPassword = "password123"; + }; + home = { config, lib, pkgs, ... }: { sydnix.impermanence = { - enable = true; + enable = false; + + directories = [ + # ".ssh" + # ".config/systemd" + ]; + + mutableDotfiles = { + enable = false; + # files = [ + # "nvim/.config/nvim/init.vim" + # "nvim/.vimrc" + # ]; + # directories = [ + # "qtile" + # ]; + }; }; home = { stateVersion = "18.09"; - packages = [ pkgs.hello ]; + packages = [ + pkgs.hello + # pkgs.wezterm + ]; }; }; } diff --git a/users/crumb/dots/nvim/.config/nvim/init.vim b/users/crumb/dots/nvim/.config/nvim/init.vim new file mode 100644 index 0000000..94cf319 --- /dev/null +++ b/users/crumb/dots/nvim/.config/nvim/init.vim @@ -0,0 +1 @@ +so ~/.vimrc diff --git a/users/crumb/dots/nvim/.vimrc b/users/crumb/dots/nvim/.vimrc new file mode 100644 index 0000000..489ba40 --- /dev/null +++ b/users/crumb/dots/nvim/.vimrc @@ -0,0 +1,2 @@ +imap jk +xmap JK