Switch to named flakes
This commit is contained in:
parent
d9266b5bf8
commit
5a1b1cd8c1
15 changed files with 88 additions and 31 deletions
scripts/Common/Scripts
|
@ -115,16 +115,29 @@ $null = New-Module {
|
|||
|
||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||
|
||||
if ($env:CONFIG_MODULE) {
|
||||
if ($env:CONFIG_NAME) {
|
||||
$output = & {
|
||||
if (-not $IsWindows) {
|
||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||
fish -c ". $escapedPath; $Script";
|
||||
} else {
|
||||
$cleanup = { };
|
||||
$projectRoot = "$PSScriptRoot/../../..";
|
||||
$archisoDir = "$projectRoot/archiso";
|
||||
|
||||
function fish {
|
||||
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
||||
}
|
||||
|
||||
if (Test-Path -PathType Container "$archisoDir") {
|
||||
$git = {
|
||||
git -C "$projectRoot" -c safe.directory="$("$(Resolve-Path $projectRoot)".Replace("\", "/"))" @args;
|
||||
};
|
||||
|
||||
& $git rm -r --cached "$archisoDir" *> $null;
|
||||
$cleanup = { & $git restore --staged "$archisoDir" };
|
||||
}
|
||||
|
||||
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||
|
||||
if (-not $?) {
|
||||
|
@ -132,6 +145,8 @@ $null = New-Module {
|
|||
} else {
|
||||
$output;
|
||||
}
|
||||
|
||||
& $cleanup *> $null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,12 +80,7 @@ $null = New-Module {
|
|||
$Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire';
|
||||
|
||||
if ($IsWindows) {
|
||||
$env:WSLENV = "CONFIG_MODULE/p";
|
||||
|
||||
if ($env:CONFIG_MODULE) {
|
||||
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
||||
}
|
||||
|
||||
$env:WSLENV = "CONFIG_NAME";
|
||||
New-Alias -Force "sudo" gsudo;
|
||||
}
|
||||
|
||||
|
@ -150,7 +145,7 @@ $null = New-Module {
|
|||
Start-Sleep 0.1;
|
||||
}
|
||||
|
||||
foreach ($name in @("CONFIG_MODULE", "INSTALLER_SCRIPT")) {
|
||||
foreach ($name in @("INSTALLER_SCRIPT")) {
|
||||
$variable = Get-Item "Env:\$name";
|
||||
|
||||
$path = Join-Path `
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#!/bin/env fish
|
||||
function isConfigured -S
|
||||
set -q "$CONFIG_MODULE"
|
||||
set -q CONFIG_NAME
|
||||
end
|
||||
|
||||
function getProfiles -S
|
||||
source "$(status dirname)/eval-flake.fish";
|
||||
evalFlake "" "" --apply "builtins.attrNames" --json
|
||||
end
|
||||
|
||||
function getConfig -S -a property
|
||||
source "$(status dirname)/eval-module.fish"
|
||||
evalModule "$CONFIG_MODULE" "$property" $argv[2..]
|
||||
source "$(status dirname)/eval-flake.fish"
|
||||
evalFlake "$CONFIG_NAME" "$property" $argv[2..]
|
||||
end
|
||||
|
||||
function getAttributes -S -a property
|
||||
|
|
26
scripts/Common/Scripts/eval-flake.fish
Executable file
26
scripts/Common/Scripts/eval-flake.fish
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/env fish
|
||||
function evalFlake --argument-names config property
|
||||
set -l argv $argv[3..]
|
||||
argparse --ignore-unknown "apply=" "json" -- $argv
|
||||
|
||||
if [ -z "$_flag_json" ]
|
||||
set -a argv --raw
|
||||
else
|
||||
set -a argv --json
|
||||
end
|
||||
|
||||
if [ -z "$_flag_apply" ]
|
||||
set _flag_apply "_: _"
|
||||
end
|
||||
|
||||
if [ -n "$config" ]
|
||||
set config ".$config"
|
||||
set _flag_apply "_: ($_flag_apply) ((import $(status dirname)/../../../lib/eval-attribute.nix) _)"
|
||||
end
|
||||
|
||||
PROPERTY="$property" \
|
||||
nix eval --impure --extra-experimental-features "nix-command flakes" \
|
||||
--apply "$_flag_apply" \
|
||||
"$(realpath (status dirname))/../../..#valhalla$config" \
|
||||
$argv
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue