about summary refs log tree commit diff
path: root/modules/nixos
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-11-23 04:20:34 +0300
committerAzat Bahawi <azat@bahawi.net>2023-11-23 04:20:34 +0300
commit67b82386d8ad8ae3eea5083bd22809f6192d92a8 (patch)
tree41829a0b3e05a9dbb4b0189e34a7b53e401f489e /modules/nixos
parent2023-11-19 (diff)
2023-11-23
Diffstat (limited to '')
-rw-r--r--modules/nixos/common/nix.nix6
-rw-r--r--modules/nixos/docker.nix9
-rw-r--r--modules/nixos/mpv.nix160
-rw-r--r--modules/nixos/podman.nix54
4 files changed, 111 insertions, 118 deletions
diff --git a/modules/nixos/common/nix.nix b/modules/nixos/common/nix.nix
index 0caf265..e21cc5c 100644
--- a/modules/nixos/common/nix.nix
+++ b/modules/nixos/common/nix.nix
@@ -2,6 +2,7 @@
   config,
   inputs,
   lib,
+  this,
   ...
 }:
 with lib; let
@@ -14,7 +15,10 @@ in {
   };
 
   config = {
-    nix.settings.trusted-users = ["@wheel"];
+    nix = mkIf this.isHeadless {
+      daemonCPUSchedPolicy = "idle";
+      daemonIOSchedClass = "idle";
+    };
 
     nixpkgs.config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages;
 
diff --git a/modules/nixos/docker.nix b/modules/nixos/docker.nix
index 31c0dda..3b38ff1 100644
--- a/modules/nixos/docker.nix
+++ b/modules/nixos/docker.nix
@@ -18,6 +18,8 @@ in {
       }
     ];
 
+    nixfiles.modules.common.shell.aliases.d = "docker";
+
     secrets.containers-auth = {
       file = "${inputs.self}/secrets/containers-auth";
       path = "${config.my.home}/.docker/config.json";
@@ -30,12 +32,5 @@ in {
     environment.systemPackages = with pkgs; [docker-compose];
 
     my.extraGroups = ["docker"];
-
-    hm.programs.bash = {
-      shellAliases.d = "docker";
-      initExtra = mkAfter ''
-        _complete_alias d _docker docker
-      '';
-    };
   };
 }
diff --git a/modules/nixos/mpv.nix b/modules/nixos/mpv.nix
index efe1729..a2b73fa 100644
--- a/modules/nixos/mpv.nix
+++ b/modules/nixos/mpv.nix
@@ -7,83 +7,87 @@ with lib; let
   cfg = config.nixfiles.modules.mpv;
 in {
   config = mkIf cfg.enable {
-    nixfiles.modules.common.xdg.defaultApplications.mpv = let
-      audio = [
-        "audio/aac"
-        "audio/ac3"
-        "audio/basic"
-        "audio/flac"
-        "audio/midi"
-        "audio/mp4"
-        "audio/mpeg"
-        "audio/ogg"
-        "audio/opus"
-        "audio/vnd.dts"
-        "audio/vnd.dts.hd"
-        "audio/webm"
-        "audio/x-adpcm"
-        "audio/x-aifc"
-        "audio/x-aiff"
-        "audio/x-ape"
-        "audio/x-flac+ogg"
-        "audio/x-m4b"
-        "audio/x-m4r"
-        "audio/x-matroska"
-        "audio/x-mpegurl"
-        "audio/x-musepack"
-        "audio/x-opus+ogg"
-        "audio/x-speex"
-        "audio/x-speex+ogg"
-        "audio/x-vorbis+ogg"
-        "audio/x-wav"
-        "audio/x-wavpack"
-        "x-content/audio-cdda"
-        "x-content/audio-dvd"
-      ];
-      video = [
-        "video/3gpp"
-        "video/3gpp2"
-        "video/mkv"
-        "video/mp2t"
-        "video/mp4"
-        "video/mpeg"
-        "video/ogg"
-        "video/quicktime"
-        "video/vnd.mpegurl"
-        "video/vnd.radgamettools.bink"
-        "video/vnd.radgamettools.smacker"
-        "video/wavelet"
-        "video/webm"
-        "video/x-matroska"
-        "video/x-matroska-3d"
-        "video/x-mjpeg"
-        "video/x-msvideo"
-        "video/x-ogm+ogg"
-        "video/x-theora+ogg"
-        "x-content/video-bluray"
-        "x-content/video-dvd"
-        "x-content/video-hddvd"
-        "x-content/video-svcd"
-        "x-content/video-vcd"
-      ];
-      image = [
-        "image/avif"
-        "image/bmp"
-        "image/gif"
-        "image/jp2"
-        "image/jpeg"
-        "image/jpg"
-        "image/jpm"
-        "image/jpx"
-        "image/jxl"
-        "image/png"
-        "image/tiff"
-        "image/vnd.microsoft.icon"
-        "image/webp"
-        "image/webp"
-        "image/x-tga"
-      ];
-    in
-      audio ++ video ++ image;
+    nixfiles.modules.common = {
+      shell.aliases.cam = "mpv av://v4l2:/dev/video0";
+
+      xdg.defaultApplications.mpv = let
+        audio = [
+          "audio/aac"
+          "audio/ac3"
+          "audio/basic"
+          "audio/flac"
+          "audio/midi"
+          "audio/mp4"
+          "audio/mpeg"
+          "audio/ogg"
+          "audio/opus"
+          "audio/vnd.dts"
+          "audio/vnd.dts.hd"
+          "audio/webm"
+          "audio/x-adpcm"
+          "audio/x-aifc"
+          "audio/x-aiff"
+          "audio/x-ape"
+          "audio/x-flac+ogg"
+          "audio/x-m4b"
+          "audio/x-m4r"
+          "audio/x-matroska"
+          "audio/x-mpegurl"
+          "audio/x-musepack"
+          "audio/x-opus+ogg"
+          "audio/x-speex"
+          "audio/x-speex+ogg"
+          "audio/x-vorbis+ogg"
+          "audio/x-wav"
+          "audio/x-wavpack"
+          "x-content/audio-cdda"
+          "x-content/audio-dvd"
+        ];
+        video = [
+          "video/3gpp"
+          "video/3gpp2"
+          "video/mkv"
+          "video/mp2t"
+          "video/mp4"
+          "video/mpeg"
+          "video/ogg"
+          "video/quicktime"
+          "video/vnd.mpegurl"
+          "video/vnd.radgamettools.bink"
+          "video/vnd.radgamettools.smacker"
+          "video/wavelet"
+          "video/webm"
+          "video/x-matroska"
+          "video/x-matroska-3d"
+          "video/x-mjpeg"
+          "video/x-msvideo"
+          "video/x-ogm+ogg"
+          "video/x-theora+ogg"
+          "x-content/video-bluray"
+          "x-content/video-dvd"
+          "x-content/video-hddvd"
+          "x-content/video-svcd"
+          "x-content/video-vcd"
+        ];
+        image = [
+          "image/avif"
+          "image/bmp"
+          "image/gif"
+          "image/jp2"
+          "image/jpeg"
+          "image/jpg"
+          "image/jpm"
+          "image/jpx"
+          "image/jxl"
+          "image/png"
+          "image/tiff"
+          "image/vnd.microsoft.icon"
+          "image/webp"
+          "image/webp"
+          "image/x-tga"
+        ];
+      in
+        audio ++ video ++ image;
+    };
   };
 }
diff --git a/modules/nixos/podman.nix b/modules/nixos/podman.nix
index 0f6db48..f6ee6bf 100644
--- a/modules/nixos/podman.nix
+++ b/modules/nixos/podman.nix
@@ -18,6 +18,8 @@ in {
       }
     ];
 
+    nixfiles.modules.common.shell.aliases.p = "podman";
+
     secrets.containers-auth = {
       file = "${inputs.self}/secrets/containers-auth";
       path = "${config.dirs.config}/containers/auth.json";
@@ -31,38 +33,26 @@ in {
 
     my.extraGroups = ["podman"];
 
-    hm = {
-      xdg.configFile = {
-        # This removes a really annoying registry search. 100% of the time I
-        # would need to look up stuff from the Docker and not Quay!
-        "containers/registries.conf".text = ''
-          [registries.search]
-          registries = ["docker.io"]
-        '';
-
-        # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting
-        # for Podman to catch up now.
-        #
-        # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666
-        "containers/storage.conf".text = optionalString config.boot.zfs.enabled ''
-          [storage]
-          driver = "overlay"
-
-          [storage.options]
-          mount_program = "${getExe' pkgs.fuse-overlayfs "fuse-overlayfs"}"
-          mountopt = "noatime,nodev,nosuid"
-        '';
-      };
-
-      programs.bash = {
-        shellAliases = {
-          podman = "grc -es ${getExe' pkgs.podman "podman"}";
-          p = "podman";
-        };
-        initExtra = mkAfter ''
-          _complete_alias p __start_podman podman
-        '';
-      };
+    hm.xdg.configFile = {
+      # This removes a really annoying registry search. 100% of the time I
+      # would need to look up stuff from the Docker and not Quay!
+      "containers/registries.conf".text = ''
+        [registries.search]
+        registries = ["docker.io"]
+      '';
+
+      # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting
+      # for Podman to catch up now.
+      #
+      # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666
+      "containers/storage.conf".text = optionalString config.boot.zfs.enabled ''
+        [storage]
+        driver = "overlay"
+
+        [storage.options]
+        mount_program = "${getExe' pkgs.fuse-overlayfs "fuse-overlayfs"}"
+        mountopt = "noatime,nodev,nosuid"
+      '';
     };
   };
 }

Consider giving Nix/NixOS a try! <3