mirror of
https://github.com/zhaofengli/attic.git
synced 2025-03-15 13:07:49 +00:00
flake: Add attic.nix-versions
This commit is contained in:
parent
3ecea8d07f
commit
09038b7663
2 changed files with 71 additions and 0 deletions
52
flake/nix-versions.nix
Normal file
52
flake/nix-versions.nix
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{ lib, flake-parts-lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
inherit (flake-parts-lib)
|
||||||
|
mkPerSystemOption
|
||||||
|
;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
perSystem = mkPerSystemOption {
|
||||||
|
options.attic.nix-versions = {
|
||||||
|
versions = mkOption {
|
||||||
|
type = types.attrsOf types.package;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
manifestFile = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
perSystem = { self', pkgs, config, ... }: let
|
||||||
|
cfg = config.attic.nix-versions;
|
||||||
|
in {
|
||||||
|
attic.nix-versions = {
|
||||||
|
versions = {
|
||||||
|
default = pkgs.nix;
|
||||||
|
"2.20" = pkgs.nixVersions.nix_2_20;
|
||||||
|
"2.24" = pkgs.nixVersions.nix_2_24;
|
||||||
|
};
|
||||||
|
|
||||||
|
manifestFile = let
|
||||||
|
manifest = lib.mapAttrs (_: nix: {
|
||||||
|
inherit nix;
|
||||||
|
shellHook = ''
|
||||||
|
export NIX_INCLUDE_PATH="${lib.getDev nix}/include"
|
||||||
|
export NIX_CFLAGS_COMPILE="-isystem $NIX_INCLUDE_PATH $NIX_CFLAGS_COMPILE"
|
||||||
|
export NIX_LDFLAGS="-L${nix}/lib $NIX_LDFLAGS"
|
||||||
|
export PKG_CONFIG_PATH="${lib.getDev nix}/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
export PATH="${lib.getBin nix}/bin:$PATH"
|
||||||
|
'';
|
||||||
|
}) cfg.versions;
|
||||||
|
in pkgs.writeText "nix-versions.json" (builtins.toJSON manifest);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
19
justfile
Normal file
19
justfile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
set positional-arguments
|
||||||
|
|
||||||
|
here := env_var_or_default("JUST_INVOCATION_DIR", invocation_directory())
|
||||||
|
base := `pwd`
|
||||||
|
|
||||||
|
#@echo "here: {{ here }}"
|
||||||
|
#@echo "base: {{ base }}"
|
||||||
|
|
||||||
|
# List available targets
|
||||||
|
list:
|
||||||
|
@just --list --unsorted
|
||||||
|
|
||||||
|
# Run a command with an alternative Nix version
|
||||||
|
with-nix version *command:
|
||||||
|
set -e; \
|
||||||
|
hook="$(jq -e -r '.[$version].shellHook' --arg version "{{ version }}" < "$NIX_VERSIONS" || (>&2 echo "Version {{ version }} doesn't exist"; exit 1))"; \
|
||||||
|
eval "$hook"; \
|
||||||
|
CARGO_TARGET_DIR="{{ base }}/target/nix-{{ version }}" \
|
||||||
|
{{ command }}
|
Loading…
Add table
Reference in a new issue