mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
Add nixBuildArgs parameter
This commit is contained in:
parent
a7cff0bb28
commit
a03feca499
5 changed files with 29 additions and 6 deletions
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
|
|
@ -32,6 +32,13 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: cachix-action
|
name: cachix-action
|
||||||
skipNixBuild: true
|
skipNixBuild: true
|
||||||
|
- name: Test nixBuildArgs parameter
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
name: cachix-action
|
||||||
|
file: test-with-arg.nix
|
||||||
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||||
|
nixBuildArgs: --argstr arg foobar
|
||||||
- name: Test private cache
|
- name: Test private cache
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ inputs:
|
||||||
description: 'Nix file to build. Defaults to default.nix'
|
description: 'Nix file to build. Defaults to default.nix'
|
||||||
attributes:
|
attributes:
|
||||||
description: 'Nix attributes to nix-build. By default, all attributes are built.'
|
description: 'Nix attributes to nix-build. By default, all attributes are built.'
|
||||||
|
nixBuildArgs:
|
||||||
|
description: 'Additional arguments for nix-build.'
|
||||||
branding:
|
branding:
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
icon: 'database'
|
icon: 'database'
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ function run() {
|
||||||
const file = core.getInput('file');
|
const file = core.getInput('file');
|
||||||
const skipNixBuild = core.getInput('skipNixBuild');
|
const skipNixBuild = core.getInput('skipNixBuild');
|
||||||
const attributes = core.getInput('attributes');
|
const attributes = core.getInput('attributes');
|
||||||
|
const nixBuildArgs = core.getInput('nixBuildArgs');
|
||||||
const name = core.getInput('name', { required: true });
|
const name = core.getInput('name', { required: true });
|
||||||
const signingKey = core.getInput('signingKey');
|
const signingKey = core.getInput('signingKey');
|
||||||
const authToken = core.getInput('authToken');
|
const authToken = core.getInput('authToken');
|
||||||
|
|
@ -84,7 +85,8 @@ function run() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const args = strings_1.prependEach('-A', strings_1.nonEmptySplit(attributes, /\s+/)).concat([file || "default.nix"]);
|
const args = strings_1.prependEach('-A', strings_1.nonEmptySplit(attributes, /\s+/)).concat([file || "default.nix"]);
|
||||||
yield exec.exec('nix-build', args, options);
|
const additionalArgs = strings_1.nonEmptySplit(nixBuildArgs, /\s+/);
|
||||||
|
yield exec.exec('nix-build', additionalArgs.concat(args), options);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/main.ts
10
src/main.ts
|
|
@ -1,7 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import {type} from 'os';
|
import { type } from 'os';
|
||||||
import {prependEach, nonEmptySplit} from './strings';
|
import { prependEach, nonEmptySplit } from './strings';
|
||||||
|
|
||||||
function home() {
|
function home() {
|
||||||
if (type() == "Darwin") {
|
if (type() == "Darwin") {
|
||||||
|
|
@ -17,6 +17,7 @@ async function run() {
|
||||||
const file = core.getInput('file');
|
const file = core.getInput('file');
|
||||||
const skipNixBuild = core.getInput('skipNixBuild');
|
const skipNixBuild = core.getInput('skipNixBuild');
|
||||||
const attributes = core.getInput('attributes');
|
const attributes = core.getInput('attributes');
|
||||||
|
const nixBuildArgs = core.getInput('nixBuildArgs');
|
||||||
const name = core.getInput('name', { required: true });
|
const name = core.getInput('name', { required: true });
|
||||||
const signingKey = core.getInput('signingKey');
|
const signingKey = core.getInput('signingKey');
|
||||||
const authToken = core.getInput('authToken')
|
const authToken = core.getInput('authToken')
|
||||||
|
|
@ -71,12 +72,13 @@ async function run() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const args = prependEach('-A', nonEmptySplit(attributes, /\s+/)).concat([file || "default.nix"]);
|
const args = prependEach('-A', nonEmptySplit(attributes, /\s+/)).concat([file || "default.nix"]);
|
||||||
await exec.exec('nix-build', args, options);
|
const additionalArgs = nonEmptySplit(nixBuildArgs, /\s+/);
|
||||||
|
await exec.exec('nix-build', additionalArgs.concat(args), options);
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`Action failed with error: ${error}`);
|
core.setFailed(`Action failed with error: ${error}`);
|
||||||
throw(error);
|
throw (error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
10
test-with-arg.nix
Normal file
10
test-with-arg.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{ arg ? null }:
|
||||||
|
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
if arg == null
|
||||||
|
then abort "arg is not set"
|
||||||
|
else writeText "test-with-arg" ''
|
||||||
|
${toString builtins.currentTime}
|
||||||
|
${arg}
|
||||||
|
''
|
||||||
Loading…
Add table
Add a link
Reference in a new issue