Skip to content

Commit

Permalink
simplify flake internals, build+cache efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Nov 1, 2022
1 parent b21e696 commit d821a1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
11 changes: 2 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@
# wayfire stuff
wayfire-unstable = prev.callPackage ./pkgs/wayfire-unstable { };
};
in
waylandPkgs // { inherit waylandPkgs; };
in waylandPkgs;
in
lib.flake-utils.eachSystem [ "aarch64-linux" "x86_64-linux" ]
(system:
Expand Down Expand Up @@ -188,13 +187,7 @@

formatter = pkgs_.nixpkgs.nixpkgs-fmt;

packages = waypkgs.waylandPkgs //
{
default = (waypkgs.linkFarmFromDrvs
"nixpkgs-wayland-pkgs"
(builtins.attrValues waypkgs.waylandPkgs)
).overrideAttrs (old: { allowSubstitutes = true; });
};
packages = (waylandOverlay (pkgs_.nixpkgs) (pkgs_.nixpkgs));
})
// {
# overlays have to be outside of eachSystem block
Expand Down
27 changes: 10 additions & 17 deletions main.nu
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ let-env CACHIX_CACHE = (
else "nixpkgs-wayland"
)

def header [ color: string text: string spacer=" ": string ] {
let text = $"($text) "
let header = $" ($text | str rpad -c $spacer -l 80)"
print -e $"(ansi $color)($header)(ansi reset)"
}

def buildDrv [ drvRef: string ] {
print -e (header yellow_reverse $"eval [($drvRef)]")
print -e $"(ansi yellow) :: eval ($drvRef)(ansi reset)"
let evalJobs = (
^nix-eval-jobs
--flake $".#($drvRef)"
Expand All @@ -22,7 +16,7 @@ def buildDrv [ drvRef: string ] {
)
print -e $evalJobs

print -e (header blue_reverse $"build [($drvRef)]")
print -e $"(ansi blue) :: build ($drvRef)(ansi reset)"
print -e ($evalJobs
| where isCached == false
| select name drvPath outputs)
Expand All @@ -34,20 +28,19 @@ def buildDrv [ drvRef: string ] {
null
}

print -e (header green_reverse $"cache [($drvRef)]")
$evalJobs | each { |drv|
print -e $"(ansi green) :: cache ($drvRef)(ansi reset)"
let pushPaths = ($evalJobs | each { |drv|
$drv.outputs | each { |outPath|
if ($outPath.out | path exists) {
($outPath.out | ^cachix push $env.CACHIX_CACHE)
null
$outPath.out
}
}
}

let output = ($evalJobs | select name outputs)
print -e ($output | flatten)
})

$output
# collect paths to push
# call cachix push once
let arg = ($pushPaths | each {|it| $"($it)(char nl)"} | str collect)
$arg | ^cachix push $env.CACHIX_CACHE | complete
}

def "main rereadme" [] {
Expand Down

0 comments on commit d821a1a

Please sign in to comment.