diff options
author | Sophie Taylor <sophie@traumapony.org> | 2017-03-26 20:17:03 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-26 20:17:03 +1000 |
commit | 62e115af5b6d5b1d6934d3e29a4046960ffcaabf (patch) | |
tree | e2a088c479681ee9cf1b90c7d5358abcfac2ec66 /pkgs/build-support | |
parent | 1f545f01bb96d885b33e9ff18ce291b85d3a69fb (diff) | |
parent | 09c91f5fea73746c2ea85b37834e7ec450923d18 (diff) | |
download | nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar.gz nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar.bz2 nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar.lz nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar.xz nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.tar.zst nixlib-62e115af5b6d5b1d6934d3e29a4046960ffcaabf.zip |
Merge branch 'master' into fetchGitRepo
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/emacs/buffer.nix | 2 | ||||
-rw-r--r-- | pkgs/build-support/fetchrepoproject/default.nix | 12 | ||||
-rw-r--r-- | pkgs/build-support/kde/wrapper.nix | 7 | ||||
-rw-r--r-- | pkgs/build-support/setup-systemd-units.nix | 83 |
4 files changed, 100 insertions, 4 deletions
diff --git a/pkgs/build-support/emacs/buffer.nix b/pkgs/build-support/emacs/buffer.nix index 1cbac0709a66..6c5e0570fd0d 100644 --- a/pkgs/build-support/emacs/buffer.nix +++ b/pkgs/build-support/emacs/buffer.nix @@ -39,6 +39,8 @@ (make-local-variable 'process-environment) (put 'process-environment 'permanent-local t) (inherit-local 'process-environment) + ; setenv modifies in place, so copy the environment first + (setq process-environment (copy-tree process-environment)) (setenv "PATH" (concat "${lib.makeSearchPath "bin" pkgs}:" (getenv "PATH"))) (inherit-local-permanent exec-path (append '(${builtins.concatStringsSep " " (map (p: "\"${p}/bin\"") pkgs)}) exec-path)) diff --git a/pkgs/build-support/fetchrepoproject/default.nix b/pkgs/build-support/fetchrepoproject/default.nix index 8d5259908d79..13a281b12d73 100644 --- a/pkgs/build-support/fetchrepoproject/default.nix +++ b/pkgs/build-support/fetchrepoproject/default.nix @@ -27,13 +27,23 @@ let in -stdenv.mkDerivation { +with stdenv.lib; +let + extraRepoInitFlags = [ + (optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}") + (optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}") + (optionalString (referenceDir != "") "--reference=${referenceDir}") + ]; +in + +stdenv.mkDerivation { buildCommand = '' mkdir .repo ${optionalString (local_manifests != []) '' mkdir ./.repo/local_manifests for local_manifest in ${concatMapStringsSep " " toString local_manifests} + do cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName) done diff --git a/pkgs/build-support/kde/wrapper.nix b/pkgs/build-support/kde/wrapper.nix index f5add12e8eca..228eb696bd9a 100644 --- a/pkgs/build-support/kde/wrapper.nix +++ b/pkgs/build-support/kde/wrapper.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, makeWrapper, buildEnv }: +{ stdenv, lib, makeWrapper, buildEnv, gtk3, dconf }: packages: @@ -47,10 +47,11 @@ stdenv.mkDerivation { --argv0 '"$0"' \ --suffix PATH : "$env/bin" \ --prefix XDG_CONFIG_DIRS : "$env/etc/xdg" \ - --prefix XDG_DATA_DIRS : "$env/share" \ + --prefix XDG_DATA_DIRS : "$env/share:${gtk3}/share/gsettings-schemas/${gtk3.name}" \ --set QML_IMPORT_PATH "$env/lib/qt5/imports" \ --set QML2_IMPORT_PATH "$env/lib/qt5/qml" \ - --set QT_PLUGIN_PATH "$env/lib/qt5/plugins" + --set QT_PLUGIN_PATH "$env/lib/qt5/plugins" \ + --prefix GIO_EXTRA_MODULES : "${dconf.lib}/lib/gio/modules" good="1" break fi diff --git a/pkgs/build-support/setup-systemd-units.nix b/pkgs/build-support/setup-systemd-units.nix new file mode 100644 index 000000000000..4fa2f42c39dc --- /dev/null +++ b/pkgs/build-support/setup-systemd-units.nix @@ -0,0 +1,83 @@ +# | Build a script to install and start a set of systemd units on any +# systemd-based system. +# +# Creates a symlink at /etc/systemd-static/${namespace} for slightly +# improved atomicity. +{ writeScriptBin +, bash +, coreutils +, systemd +, runCommand +, lib +}: + { units # : AttrSet String (Either Path { path : Path, wanted-by : [ String ] }) + # ^ A set whose names are unit names and values are + # either paths to the corresponding unit files or a set + # containing the path and the list of units this unit + # should be wanted-by (none by default). + # + # The names should include the unit suffix + # (e.g. ".service") + , namespace # : String + # The namespace for the unit files, to allow for + # multiple independent unit sets managed by + # `setupSystemdUnits`. + }: + let static = runCommand "systemd-static" {} + '' + mkdir -p $out + ${lib.concatStringsSep "\n" (lib.mapAttrsToList (nm: file: + "ln -sv ${file.path or file} $out/${nm}" + ) units)} + ''; + add-unit-snippet = name: file: + '' + oldUnit=$(readlink -f "$unitDir/${name}" || echo "$unitDir/${name}") + if [ -f "$oldUnit" -a "$oldUnit" != "${file.path or file}" ]; then + unitsToStop+=("${name}") + fi + ln -sf "/etc/systemd-static/${namespace}/${name}" \ + "$unitDir/.${name}.tmp" + mv -T "$unitDir/.${name}.tmp" "$unitDir/${name}" + ${lib.concatStringsSep "\n" (map (unit: + '' + mkdir -p "$unitDir/${unit}.wants" + ln -sf "../${name}" \ + "$unitDir/${unit}.wants/.${name}.tmp" + mv -T "$unitDir/${unit}.wants/.${name}.tmp" \ + "$unitDir/${unit}.wants/${name}" + '' + ) file.wanted-by or [])} + unitsToStart+=("${name}") + ''; + in + writeScriptBin "setup-systemd-units" + '' + #!${bash}/bin/bash -e + export PATH=${coreutils}/bin:${systemd}/bin + + unitDir=/etc/systemd/system + if [ ! -w "$unitDir" ]; then + unitDir=/etc/systemd-mutable/system + mkdir -p "$unitDir" + fi + declare -a unitsToStop unitsToStart + + oldStatic=$(readlink -f /etc/systemd-static/${namespace} || true) + if [ "$oldStatic" != "${static}" ]; then + ${lib.concatStringsSep "\n" + (lib.mapAttrsToList add-unit-snippet units)} + if [ ''${#unitsToStop[@]} -ne 0 ]; then + echo "Stopping unit(s) ''${unitsToStop[@]}" >&2 + systemctl stop "''${unitsToStop[@]}" + fi + mkdir -p /etc/systemd-static + ln -sfT ${static} /etc/systemd-static/.${namespace}.tmp + mv -T /etc/systemd-static/.${namespace}.tmp /etc/systemd-static/${namespace} + systemctl daemon-reload + echo "Starting unit(s) ''${unitsToStart[@]}" >&2 + systemctl start "''${unitsToStart[@]}" + else + echo "Units unchanged, doing nothing" >&2 + fi + '' |