summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMichael Peyton Jones <me@michaelpj.com>2018-08-15 10:59:44 +0100
committerMichael Peyton Jones <me@michaelpj.com>2018-08-16 21:23:34 +0100
commit1b11fdd0df2254a762a16d04e603ba99e42169c0 (patch)
tree46695718d533092fb986a0a73d8260b1da306ec2 /nixos
parent13e2e19158bcd2b4d53e452d82f62817194100ef (diff)
downloadnixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar.gz
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar.bz2
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar.lz
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar.xz
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.tar.zst
nixlib-1b11fdd0df2254a762a16d04e603ba99e42169c0.zip
system-path: allow other modules to provide setup fragments
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/config/system-path.nix19
-rw-r--r--nixos/modules/config/xdg/mime.nix10
-rw-r--r--nixos/modules/misc/documentation.nix8
3 files changed, 26 insertions, 11 deletions
diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix
index a07a40e86bd1..6d17ca316e00 100644
--- a/nixos/modules/config/system-path.nix
+++ b/nixos/modules/config/system-path.nix
@@ -81,6 +81,12 @@ in
         description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
       };
 
+      extraSetup = mkOption {
+        type = types.lines;
+        default = [ ];
+        description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.";
+      };
+
     };
 
     system = {
@@ -134,17 +140,8 @@ in
           if [ -x $out/bin/glib-compile-schemas -a -w $out/share/glib-2.0/schemas ]; then
               $out/bin/glib-compile-schemas $out/share/glib-2.0/schemas
           fi
-
-          if [ -x $out/bin/install-info -a -w $out/share/info ]; then
-            shopt -s nullglob
-            for i in $out/share/info/*.info $out/share/info/*.info.gz; do
-                $out/bin/install-info $i $out/share/info/dir
-            done
-          fi
-        '' ++ optionalString config.xdg.mime.enable ''
-          XDG_DATA_DIRS=$out/share ${pkgs.shared-mime-info}/bin/update-mime-database -V $out/share/mime > /dev/null
-
-          ${pkgs.desktop-file-utils}/bin/update-desktop-database $out/share/applications
+          
+          ${config.environment.extraSetup}
         '';
     };
 
diff --git a/nixos/modules/config/xdg/mime.nix b/nixos/modules/config/xdg/mime.nix
index db3e7c6d4c53..f1b672234a34 100644
--- a/nixos/modules/config/xdg/mime.nix
+++ b/nixos/modules/config/xdg/mime.nix
@@ -21,6 +21,16 @@ with lib;
       # this package also installs some useful data, as well as its utilities 
       pkgs.shared-mime-info 
     ];
+
+    environment.extraSetup = ''
+      if [ -w $out/share/mime ]; then
+        XDG_DATA_DIRS=$out/share ${pkgs.shared-mime-info}/bin/update-mime-database -V $out/share/mime > /dev/null
+      fi
+
+      if [ -w $out/share/applications ]; then
+        ${pkgs.desktop-file-utils}/bin/update-desktop-database $out/share/applications
+      fi
+    '';
   };
 
 }
diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix
index b482a5a67523..e6ccda5d7f40 100644
--- a/nixos/modules/misc/documentation.nix
+++ b/nixos/modules/misc/documentation.nix
@@ -82,6 +82,14 @@ let cfg = config.documentation; in
       environment.systemPackages = [ pkgs.texinfoInteractive ];
       environment.pathsToLink = [ "/share/info" ];
       environment.extraOutputsToInstall = [ "info" ] ++ optional cfg.dev.enable "devinfo";
+      environment.extraSetup = ''
+        if [ -w $out/share/info ]; then
+          shopt -s nullglob
+          for i in $out/share/info/*.info $out/share/info/*.info.gz; do
+              ${pkgs.texinfo}/bin/install-info $i $out/share/info/dir
+          done
+        fi
+      '';
     })
 
     (mkIf cfg.doc.enable {