-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33dccfe
commit ae682f1
Showing
4 changed files
with
93 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/.flox | ||
result | ||
result-* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,103 @@ | ||
{ self, inputs, lib, buildEnv, runCommand, bash, coreutils, hostPlatform, system }: | ||
# ============================================================================ # | ||
# | ||
# Creates a starter `<env>/etc/profile' that aggregates | ||
# `<env>/etc/profile.d/*.sh' "child scripts". | ||
# | ||
# ---------------------------------------------------------------------------- # | ||
|
||
{ self, inputs, lib, config, bash, coreutils, hostPlatform, system }: let | ||
|
||
let | ||
pname = "etc-profiles"; | ||
version = "0.1.0-${lib.flox-floxpkgs.getRev self}"; | ||
src = self; | ||
ld-floxlib = inputs.ld-floxlib.packages.ld-floxlib; | ||
# ---------------------------------------------------------------------------- # | ||
|
||
splitSname = script: let | ||
sname = baseNameOf script; | ||
m = builtins.match "([^_]*)_(.*).sh" sname; | ||
bname = builtins.elemAt m 1; | ||
in { | ||
inherit sname bname; | ||
priority = builtins.head m; | ||
pname = "profile-" + bname; | ||
ldFloxlib = inputs.ld-floxlib.packages.ld-floxlib; | ||
pname = "etc-profiles"; | ||
version = "0.1.0-${lib.flox-floxpkgs.getRev self}"; | ||
drv = derivation { | ||
inherit pname version system ldFloxlib; | ||
name = pname + "-" + version; | ||
builder = bash.outPath + "/bin/bash"; | ||
outputs = ["common_paths" "node" "python3" "out"]; | ||
profile = builtins.path { path = ( toString self ) + "/profile"; }; | ||
profile_d = builtins.path { path = ( toString self ) + "/profile.d"; }; | ||
PATH = coreutils.outPath + "/bin"; | ||
args = ["-eu" "-o" "pipefail" "-c" '' | ||
mkdir -p "$out/etc" \ | ||
"$out/lib" \ | ||
"$common_paths/etc/profile.d" \ | ||
"$node/etc/profile.d" \ | ||
"$python3/etc/profile.d" \ | ||
; | ||
cp -- "$profile" "$out/etc/profile"; | ||
${if ! hostPlatform.isLinux then "" else '' | ||
ln -s -- "$ldFloxlib/lib/"* "$out/lib/"; | ||
'' | ||
} | ||
cp -- "$profile_d/0100_common-paths.sh" "$common_paths/etc/profile.d/"; | ||
cp -- "$profile_d/0500_node.sh" "$node/etc/profile.d/"; | ||
cp -- "$profile_d/0500_python3.sh" "$python3/etc/profile.d/"; | ||
'']; | ||
}; | ||
|
||
base = import ./base.nix { | ||
inherit self version bash coreutils hostPlatform ld-floxlib lib system; | ||
}; | ||
|
||
mkEtcProfile = import ./mk-profile.nix { | ||
inherit bash coreutils system; | ||
version = base.version; | ||
}; | ||
# --------------------------------------------------------------------------- # | ||
|
||
mkProfileLocal = { | ||
script | ||
, description ? null | ||
, longDescription ? null | ||
, ... | ||
} @ args: let | ||
ss = splitSname script; | ||
in drv // { | ||
meta = let | ||
lfm = ldFloxlib.meta or {}; | ||
license = lib.licenses.mit; | ||
# Inherit broken from `ld-floxlib' | ||
broken = if hostPlatform.isLinux then ( lfm.broken or false ) else false; | ||
platforms = [ | ||
"x86_64-linux" "aarch64-linux" "i686-linux" | ||
"x86_64-darwin" "aarch64-darwin" | ||
]; | ||
unsupported = ! ( builtins.elem hostPlatform.system platforms ); | ||
unfree = ! license.free; | ||
in { | ||
name = lib.replaceStrings ["-"] ["_"] ss.bname; | ||
value = lib.makeOverridable mkEtcProfile ( | ||
( removeAttrs ss ["bname"] ) // args | ||
); | ||
}; | ||
inherit (drv) name; | ||
inherit license broken platforms unfree unsupported; | ||
available = ( config.allowBroken || ( ! broken ) ) && | ||
( config.allowUnfree || ( ! unfree ) ) && | ||
( config.allowUnsupportedSystem || ( ! unsupported ) ); | ||
homepage = "https://github.com/flox/etc-profiles"; | ||
outputsToInstall = ["common_paths" "python3" "node" "out"]; | ||
description = '' | ||
Installable /etc/profile.d activation scripts for use with flox | ||
''; | ||
longDescription = '' | ||
An `<env>/etc/profile' script to source `<env>/etc/profile.d/*.sh` | ||
profiles = builtins.listToAttrs ( map mkProfileLocal [ | ||
{ script = src + "/profile.d/0100_common-paths.sh"; } | ||
{ script = src + "/profile.d/0500_node.sh"; } | ||
{ script = src + "/profile.d/0500_python3.sh"; } | ||
] ); | ||
Users can define and install scripts in `<env>/etc/profile.d' as | ||
"custom packages"/installables to share common setup processes | ||
across environments. | ||
etcProfiles = buildEnv { | ||
name = pname + "-" + version; | ||
paths = [ base ] ++ (builtins.attrValues profiles); | ||
Recommended usage: | ||
# flox.nix | ||
{ | ||
packages.nixpkgs-flox.sqlite = { | ||
meta.outputsToInstall = ["bin" "out" "dev"]; | ||
}; | ||
# Provides developer environment hooks for use with python3. | ||
packages.flox.etc-profiles = { | ||
# Optionally, specify language packages to install. | ||
# Please note that all/most language packs depend on including | ||
# the "common_paths" output, and ALL depend on "out". | ||
meta.outputsToInstall = ["out" "common_paths" "python3"]; | ||
}; | ||
shell.hook = '${""}' | ||
[[ -r "$FLOX_ENV/etc/profile" ]] && . "$FLOX_ENV/etc/profile"; | ||
pkg-config --list-all >&2; | ||
'${""}' | ||
} | ||
''; | ||
}; | ||
} | ||
|
||
|
||
in runCommand "etc-profiles.${version}" { | ||
inherit pname version; | ||
outputs = [ "out" "base" ] ++ (builtins.attrNames profiles); | ||
meta.description = "Installable /etc/profile.d activation scripts for use with flox"; | ||
} '' | ||
cp -R -- ${etcProfiles}/. $out | ||
cp -R -- ${base}/. $base | ||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (output: outpath: | ||
"cp -R -- ${outpath}/. \$${output}") profiles)} | ||
'' | ||
# ---------------------------------------------------------------------------- # | ||
# | ||
# | ||
# | ||
# ============================================================================ # |
This file was deleted.
Oops, something went wrong.