Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
style: formatting for nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Mar 14, 2024
1 parent 3aeaef1 commit b6fac06
Showing 1 changed file with 55 additions and 52 deletions.
107 changes: 55 additions & 52 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,65 @@
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz";
};

outputs = {
self,
flake-schemas,
nixpkgs,
bluebuild,
utility-flake,
}: let
supportedSystems = ["x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux"];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {inherit system;};
});
in {
schemas = flake-schemas.schemas;
outputs =
{ self
, flake-schemas
, nixpkgs
, bluebuild
, utility-flake
,
}:
let
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs { inherit system; };
});
in
{
schemas = flake-schemas.schemas;

checks = forEachSupportedSystem ({ pkgs }: {
inherit (utility-flake.checks.${pkgs.system}) pre-commit-check;
});
checks = forEachSupportedSystem ({ pkgs }: {
inherit (utility-flake.checks.${pkgs.system}) pre-commit-check;
});

packages = forEachSupportedSystem ({
pkgs,
}: {
inherit (utility-flake.packages.${pkgs.system}) cosign-generate;

build-image = pkgs.writers.writeNuBin "build-image" ''
def "main" [--prefix (-p): string, ...recipes: string] {
mut recipe_prefix: string = ""
if $prefix != null {
$recipe_prefix = $"($prefix)\/"
}
let final_prefix = $recipe_prefix
packages = forEachSupportedSystem ({ pkgs
,
}: {
inherit (utility-flake.packages.${pkgs.system}) cosign-generate;

$recipes | par-each { |recipe| do {${bluebuild.packages.${pkgs.system}.bluebuild}/bin/bluebuild build $"config/recipes/($final_prefix)($recipe).yml" } out> $"/tmp/bluebuild-($recipe).log" & }
}
'';
build-image = pkgs.writers.writeNuBin "build-image" ''
def "main" [--prefix (-p): string, ...recipes: string] {
mut recipe_prefix: string = ""
if $prefix != null {
$recipe_prefix = $"($prefix)\/"
}
let final_prefix = $recipe_prefix
# This script is surprisingly fast!
generate-logo = pkgs.writers.writeNuBin "generate-logo" ''
def "main" [inputFile: string, outputFolder: string, outputName: string, extension: string, ...rest] {
mkdir $outputFolder
[ 16 32 64 128 256 ] | par-each {
|size| do { ${pkgs.lib.getExe pkgs.ffmpeg} -y -i $inputFile -vf $"scale=($size):($size)" $"($outputFolder)/($outputName)-($size)x($size).($extension)" }
$recipes | par-each { |recipe| do {${bluebuild.packages.${pkgs.system}.bluebuild}/bin/bluebuild build $"config/recipes/($final_prefix)($recipe).yml" } out> $"/tmp/bluebuild-($recipe).log" & }
}
${pkgs.lib.getExe pkgs.ffmpeg} -y -i $inputFile $"($outputFolder)/($outputName).($extension)" &
}
'';
});
'';

devShells = forEachSupportedSystem ({
pkgs,
}: {
default = pkgs.mkShell {
inherit (self.checks.${pkgs.system}.pre-commit-check) shellHook;
packages = with pkgs; [ bluebuild.packages.${system}.bluebuild nushell git jq yq ];
};
});
};
# This script is surprisingly fast!
generate-logo = pkgs.writers.writeNuBin "generate-logo" ''
def "main" [inputFile: string, outputFolder: string, outputName: string, extension: string, ...rest] {
mkdir $outputFolder
[ 16 32 64 128 256 ] | par-each {
|size| do { ${pkgs.lib.getExe pkgs.ffmpeg} -y -i $inputFile -vf $"scale=($size):($size)" $"($outputFolder)/($outputName)-($size)x($size).($extension)" }
}
${pkgs.lib.getExe pkgs.ffmpeg} -y -i $inputFile $"($outputFolder)/($outputName).($extension)" &
}
'';
});

formatter = forEachSupportedSystem ({ pkgs }: pkgs.nixpkgs-fmt);

devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
inherit (self.checks.${pkgs.system}.pre-commit-check) shellHook;
packages = with pkgs; [ bluebuild.packages.${system}.bluebuild nushell git jq yq ];
};
});
};
}

0 comments on commit b6fac06

Please sign in to comment.