Skip to content

Commit

Permalink
flake/main: more CI/nushell fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Nov 4, 2022
1 parent edafc92 commit 55520f7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/advance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
experimental-features = nix-command flakes ca-references
experimental-features = nix-command flakes
extra-binary-caches = https://nixpkgs-wayland.cachix.org
extra-trusted-public-keys = nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
experimental-features = nix-command flakes ca-references
experimental-features = nix-command flakes
extra-binary-caches = https://nixpkgs-wayland.cachix.org
extra-trusted-public-keys = nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
experimental-features = nix-command flakes ca-references
experimental-features = nix-command flakes
extra-binary-caches = https://nixpkgs-wayland.cachix.org
extra-trusted-public-keys = nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,10 @@
++ (with pkgs_.nixpkgs; [
nushell
cacert
curl
git
jq
mercurial
openssh
ripgrep
parallel
sd
inputs.nix-eval-jobs.outputs.packages.${system}.default
]);
};
Expand Down
20 changes: 14 additions & 6 deletions main.nu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let-env CACHIX_SIGNING_KEY = $env.CACHIX_SIGNING_KEY_NIXPKGS_WAYLAND

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

Expand Down Expand Up @@ -98,6 +98,7 @@ def updatePkgs [] {
}

def buildDrv [ drvRef: string ] {
header "white_reverse" $"build ($drvRef)" " "
header "blue_reverse" $"eval ($drvRef)"
let evalJobs = (
^nix-eval-jobs
Expand All @@ -113,7 +114,7 @@ def buildDrv [ drvRef: string ] {

$evalJobs
| where isCached == false
| each { |drv| (do -c {^nix build $drv.drvPath} | complete )}
| each { |drv| do -c { ^nix build $drv.drvPath } }

header "purple_reverse" $"cache: calculate paths: ($drvRef)"
let pushPaths = ($evalJobs | each { |drv|
Expand All @@ -132,7 +133,8 @@ def buildDrv [ drvRef: string ] {
}

def "main rereadme" [] {
header "red_reverse" $"readme"
let color = "yellow"
header $"($color)_reverse" $"readme"
let packageNames = (nix eval --json $".#packages.($system)" --apply 'x: builtins.attrNames x' | str trim | from json)
let pkgList = ($packageNames | where ($it != "default"))
let delimStart = "<!--pkgs-start-->"
Expand All @@ -153,18 +155,24 @@ def "main rereadme" [] {
$pkgrows
$delimEnd
]
let tableText = ($rows | str join "\n")
let tableText = ($rows | flatten | str join "\n")

let regexString = ([ '(?s)(.*)' $delimStart '(.*)' $delimEnd '(.*)' ] | str join '')
let replaceText = $"\$1($tableText)\$3"
^rg --multiline $regexString "README.md" --replace $replaceText | save --raw README2.md
mv README2.md README.md

# ^git commit -m "auto-update: updated readme" "./README.md"

let ec = ((do -c { ^git diff --exit-code "README.md" } | complete).exit_code)
if ($ec == 1) {
^git commit -m "auto-update: updated readme" "./README.md"
} else {
print -e $"(ansi $color)readme: nothing to commit(ansi reset)"
}
}

def "main build" [] {
buildDrv $"packages.($system)"
buildDrv $"devShells.($system).default.inputDerivation"
}

def flakeAdvance [] {
Expand Down

0 comments on commit 55520f7

Please sign in to comment.