Skip to content

Commit

Permalink
personalize formatting after switch from nixfmt to nixpkgs-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed Jan 17, 2022
1 parent 8ee9231 commit 0adeff6
Showing 1 changed file with 44 additions and 57 deletions.
101 changes: 44 additions & 57 deletions pkgs/cicero/evaluators/nix/lib.nix
Expand Up @@ -96,15 +96,11 @@ rec {
escape = builtins.replaceStrings
(from ++ [ "/" ])
(to ++ [ "-" ]);
in
lib.mapAttrs'
(k: v: lib.nameValuePair (escape k) (v // {
group = builtins.mapAttrs
(k: v: v // {
task = lib.mapAttrs' (k: lib.nameValuePair (escape k)) v.task or { };
}) v.group or { };
}))
job;
in lib.mapAttrs' (k: v: lib.nameValuePair (escape k) (v // {
group = builtins.mapAttrs (k: v: v // {
task = lib.mapAttrs' (k: lib.nameValuePair (escape k)) v.task or { };
}) v.group or { };
})) job;

singleTask = name: task: { ${name}.group.${name}.task.${name} = task; };
};
Expand All @@ -113,11 +109,12 @@ rec {
let
runner = "run-${language}";
scriptName = builtins.hashString "md5" script;
in
{
in {
config = {
packages =
[ "github:input-output-hk/cicero/${self.rev or ""}#${runner}" ];
packages = [
"github:input-output-hk/cicero/${self.rev or ""}#${runner}"
];

command = [
# It is ok to hard-code the system here
# because we only care about the derivation name.
Expand Down Expand Up @@ -162,14 +159,11 @@ rec {
using `data-merge.merge`.
*/
chain = action: steps:
lib.foldr
(a: b:
if builtins.typeOf a == "set"
then data-merge.merge b a
else (a action) b
)
{ }
steps;
lib.foldr (a: b:
if builtins.typeOf a == "set"
then data-merge.merge b a
else (a action) b
) { } steps;

jobs = {
escapeNames = from: to: actions: jobs.escapeNames from to;
Expand Down Expand Up @@ -244,70 +238,63 @@ rec {
config.packages = next.config.packages or [ ];
})
{
config.packages = data-merge.append
[ "github:input-output-hk/nomad-driver-nix/wrap-nix#wrap-nix" ];
config.packages = data-merge.append [
"github:input-output-hk/nomad-driver-nix/wrap-nix#wrap-nix"
];

env.NIX_CONFIG = ''
experimental-features = nix-command flakes
${next.env.NIX_CONFIG or ""}
'';
};

develop = action: next:
nix.install action (wrapScript "bash"
(next: ''
nix.install action (
wrapScript "bash" (next: ''
nix --extra-experimental-features 'nix-command flakes' \
develop -c ${lib.escapeShellArgs next}
'')
action
next);
'') action next
);

build = action: next:
nix.install action (wrapScript "bash"
(next: ''
nix.install action (
wrapScript "bash" (next: ''
if [[ -f flake.nix ]]; then
nix build
else
nix-build
fi
${lib.escapeShellArgs next}
'')
action
next);
'') action next
);
};

makes = target: action: next:
data-merge.merge
(wrapScript "bash"
(next: ''
m ${lib.escapeShellArg target}
${lib.escapeShellArgs next}
'')
action
next
)
(wrapScript "bash" (next: ''
m ${lib.escapeShellArg target}
${lib.escapeShellArgs next}
'') action next)
{
config.packages = data-merge.append [ "github:fluidattacks/makes" ];
};

git.clone = { clone_url, sha, ... }:
action: next:
data-merge.merge
(wrapScript "bash"
(next: ''
export SSL_CERT_FILE=/current-profile/etc/ssl/certs/ca-bundle.crt
export HOME="$PWD/.home"
mkdir -p "$HOME"
git config --global advice.detachedHead false
git clone --quiet ${lib.escapeShellArg clone_url} src
cd src
git checkout ${lib.escapeShellArg sha}
${lib.escapeShellArgs next}
'')
action
next)
(wrapScript "bash" (next: ''
export SSL_CERT_FILE=/current-profile/etc/ssl/certs/ca-bundle.crt
export HOME="$PWD/.home"
mkdir -p "$HOME"
git config --global advice.detachedHead false
git clone --quiet ${lib.escapeShellArg clone_url} src
cd src
git checkout ${lib.escapeShellArg sha}
${lib.escapeShellArgs next}
'') action next)
{
config.packages = data-merge.append [
"github:NixOS/nixpkgs/${self.inputs.nixpkgs.rev}#gitMinimal"
Expand Down

0 comments on commit 0adeff6

Please sign in to comment.