Skip to content

Commit

Permalink
Reorganize config
Browse files Browse the repository at this point in the history
  • Loading branch information
573 committed Sep 30, 2024
1 parent e69a76a commit 1475ae7
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
- nix-command: eval .#apps.$_system.setup.program
system: x86_64

- nix-command: eval .#devShells.$_system.ghcwasm
system: x86_64

- nix-command: build .#homeConfigurations."dani@maiziedemacchiato".activationPackage
system: x86_64
deploy-agent: maiziedemacchiato
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/ci_shells.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Build and test flake devshells (using gh caches)

on:
push:
workflow_dispatch:
workflow_call:
inputs:
branch:
description: Branch name to build on
default: ""
required: false
type: string
secrets:
CACHIX_ACTIVATE_TOKEN:
CACHIX_AUTH_TOKEN:
required: true

jobs:
nix:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
yamlbasename:
- ci_shells.yml
os:
- ubuntu-latest
system:
- aarch64
- x86_64
include:
- shell: jdk21
- shell: jvmlanguages-devenv
- shell: deno
- shell: flutter
- shell: ocaml
- shell: ruby
- shell: rubyNix
- shell: rubyShell
- shell: rust
- shell: rustwasm32
- shell: haskell
- shell: yaocaml
- shell: rustyShell
- shell: python
- shell: agda
- shell: commonlisp
- shell: playwright
- shell: playwright2
- shell: ghcwasm
- shell: haskell2

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Free Disk Space (Ubuntu)
if: contains(matrix.shell, 'ruby')
env:
_system: ${{ matrix.system }}-linux
uses: jlumbroso/free-disk-space@main
continue-on-error: true
with:
tool-cache: true

- name: Set Swap Space
uses: actionhippie/swap-space@master
with:
size: 20G

- name: Install qemu-user-static (aarch64)
if: matrix.system == 'aarch64'
env:
_system: ${{ matrix.system }}-linux
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo apt-get update --allow-releaseinfo-change
sudo apt-get update
sudo apt-get install -y qemu-user-static

- name: Quick install
env:
_system: ${{ matrix.system }}-linux
uses: cachix/install-nix-action@v29
with:
install_url: 'https://releases.nixos.org/nix/nix-2.24.8/install'
extra_nix_config: |
substituters = https://cache.nixos.org/ https://nix-community.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
keep-going = true
show-trace = true
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
keep-outputs = true
${{ matrix.system == 'aarch64' && 'system = aarch64-linux # enables binfmt on that machine, see https://nixos.wiki/wiki/NixOS_on_ARM#Compiling_through_binfmt_QEMU' || '' }}

- name: Restore and cache Nix store
env:
_system: ${{ matrix.system }}-linux
uses: nix-community/cache-nix-action@v5
with:
# save a new cache every time ci file changes
primary-key: cache-${{ matrix.os }}-${{ hashFiles('.github/workflows/ci.yaml') }}
restore-prefixes-first-match: cache-${{ matrix.os }}-
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: cache-${{ matrix.os }}-
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never
# and collect garbage in the Nix store until it reaches this size in bytes
gc-max-store-size: 8000000000

- name: Setup cachix
env:
_system: ${{ matrix.system }}-linux
uses: cachix/cachix-action@v15
with:
name: 573-bc
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Eval
env:
_system: ${{ matrix.system }}-linux
run: |
echo "::group::Eval command"
cachix use 573-bc
cachix use nix-on-droid
${{ (matrix.system == 'aarch64') && 'cachix watch-exec 573-bc -- \' || '' }}
nix ${{ 'eval .#devShells.$_system.'matrix.shell }}

- name: Deploy cachix-agent spec
if: github.ref == 'refs/heads/wsl2' && matrix.deploy-agent
env:
CACHIX_ACTIVATE_TOKEN: ${{ secrets.CACHIX_ACTIVATE_TOKEN }}
TEST: ${{ matrix.system == 'aarch64' && '--impure' || '' }}
run: |
echo "::group::Build spec"
spec="$(nix build --print-out-paths ".#cachix-deploy-spec-${{ matrix.deploy-agent }}" ${{ (matrix.system == 'aarch64' || contains(matrix.nix-command, 'develop')) && '--impure' || '' }})"

echo "::group::Upload spec"
cachix push 573-bc "$spec"

# vim: set sw=2:
14 changes: 7 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -663,17 +663,17 @@ poetry2nix.inputs.nixpkgs.follows = "unstable";
(mkDevenvHaskell system "haskell" { inherit haskellPackages mkShell; })
(mkDevShellOcaml system "yaocaml" { inherit unstable; })
(mkDevenvRust2 system "rustyShell" { inherit inputs mkShell; })
#(mkDevShellPython system "python" { inherit unstable; })
(mkDevShellPython system "python" { inherit unstable; })
# DONT probably delusional, rather try https://sourcegraph.com/github.com/nixvital/ml-pkgs/-/blob/overlays/torch-family.nix
# also: https://wiki.nixos.org/wiki/CUDA
#(mkDevShellCudaWsl system "cudawsl" { })
#(mkDevenvJulia system "julia" { })
(mkDevShellAgda system "agda" { inherit ghc-nixpkgs-unstable haskellPackages; })
#(mkDevShellCommonLisp system "commonlisp" { inherit unstable; })
#(mkDevenvPlaywright "playwright" { inherit nixpkgs mkShell; })
#(mkDevenvPlaywright2 "playwright2" { inherit unstable mkShell; })
#(mkDevShellGhcwasm "ghcwasm" { inherit ghc-wasm-meta unstable; })
# (mkDevenvHaskell2 "haskell2" { inherit nixpkgs ghciwatch haskellPackages unstable mkShell; })
(mkDevShellAgda system "agda" { inherit haskellPackages; })
(mkDevShellCommonLisp system "commonlisp" { })
(mkDevenvPlaywright system "playwright" { inherit nixpkgs mkShell; })
(mkDevenvPlaywright2 system "playwright2" { inherit unstable mkShell; })
(mkDevShellGhcwasm system "ghcwasm" { inherit ghc-wasm-meta; })
(mkDevenvHaskell2 system "haskell2" { inherit nixpkgs ghciwatch haskellPackages unstable mkShell; })
] /*// {
#template = (nixpkgs.mkShell.override { stdenv = nixpkgs.stdenvAdapters.useMoldLinker nixpkgs.stdenv; });
# https://github.com/NixOS/nixpkgs/blob/9e860e4/pkgs/development/lisp-modules/shell.nix
Expand Down
3 changes: 2 additions & 1 deletion flake/builders/mkDevShellAgda.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ system, ghcpkgsFor, inputs, name, args, ... }:
{ system, ghcpkgsFor, name, args, ... }:
let
pkgs = ghcpkgsFor.${system};
myagda = (pkgs.agdaPackages.override {
Expand All @@ -11,5 +11,6 @@ let
});
in
pkgs.mkShell {
inherit name;
packages = [ myagda ];
}
5 changes: 3 additions & 2 deletions flake/builders/mkDevShellCommonLisp.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ system, pkgsFor, name, args, ... }:
# https://github.com/NixOS/nixpkgs/blob/9e860e4/pkgs/development/lisp-modules/shell.nix
let
pkgs = unstable;
pkgs = pkgsFor.${system};
in
pkgs.mkShell {
inherit name;
nativeBuildInputs = [
(pkgs.sbcl.withPackages
(sbclPackageSet: builtins.attrValues {
Expand All @@ -19,4 +20,4 @@ pkgs.mkShell {
;
}))
];
};
}
6 changes: 3 additions & 3 deletions flake/builders/mkDevShellGhcwasm.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ system, pkgsFor, name, args, ... }:
# https://github.com/tweag/ormolu/blob/74887f00137d6cd91811440325c3ac330a371b2c/ormolu-live/default.nix
let
inherit (args) unstable ghc-wasm-meta;
pkgs = unstable;
pkgs = pkgsFor.${system};
in
pkgs.mkShell {
packages = [ ghc-wasm-meta ];
inherit name;
packages = [ args.ghc-wasm-meta ];
}
5 changes: 4 additions & 1 deletion flake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ let

pkgsCudaFor = forEachSystem (system: import ./nixpkgs.nix { inherit inputs rootPath system;
config = {
#allowUnfree = true;
cudnnSupport = true;
cudaVersion = "12";
# https://discourse.nixos.org/t/laggy-mouse-when-use-nvidia-driver/38410
nvidia.acceptLicense = true;
cudaSupport = true;
# https://discourse.nixos.org/t/too-dumb-to-use-allowunfreepredicate/39956/17
allowUnfreePredicate = pkg: builtins.elem (inputs.nixpkgs.lib.getName pkg) [
Expand Down
24 changes: 5 additions & 19 deletions flake/nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@
, pkgsSet ? inputs.nixpkgs
, nixOnDroid ? false
, config ? {
# FIXME https://discourse.nixos.org/t/unexpected-11h-build-after-auto-update/39907/9
#allowAliases = false;
#allowUnfree = true;
#cudaSupport = true;
#cudnnSupport = true;
#cudaVersion = "12";
# https://discourse.nixos.org/t/laggy-mouse-when-use-nvidia-driver/38410
nvidia.acceptLicense = true;
# FIXME https://discourse.nixos.org/t/unexpected-11h-build-after-auto-update/39907/9
allowAliases = false;
allowUnfreePredicate = pkg: builtins.elem (inputs.nixpkgs.lib.getName pkg) [
"google-chrome"
];
}
}:
import pkgsSet {
inherit config system rootPath;
#config = {
# permittedInsecurePackages = [ "openssl-1.1.1w" ];
# };
overlays =
[
#inputs.rust-overlay.overlays.default # now commented out due to: error: attribute 'rust-analyzer' missing https://github.com/573/nix-config-1/actions/runs/4923802480/jobs/8796067915#step:6:826 # rustc still 1.64 when building as opposed to nix shell 1.67
Expand Down Expand Up @@ -123,13 +117,5 @@ import pkgsSet {
inputs.nix-on-droid.overlays.default
# prevent uploads to remote builder, https://ryantm.github.io/nixpkgs/functions/prefer-remote-fetch
(final: prev: prev.prefer-remote-fetch final prev)
(final: prev: {
# https://discourse.nixos.org/t/overriding-torch-with-torch-bin-for-all-packages/37086/2
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(py-final: py-prev: {
torch = py-final.torch-bin;
})
];
})
];
}

0 comments on commit 1475ae7

Please sign in to comment.