diff options
| -rw-r--r-- | .github/workflows/update-inputs.yaml | 37 | ||||
| -rw-r--r-- | .github/workflows/update-lock.yaml | 34 | ||||
| -rw-r--r-- | README.md | 176 | ||||
| -rw-r--r-- | default.nix | 18 | ||||
| -rw-r--r-- | flake.lock | 118 | ||||
| -rw-r--r-- | flake.nix | 32 | ||||
| -rw-r--r-- | garnix.yaml | 2 | ||||
| -rw-r--r-- | hci.nix | 38 | ||||
| -rw-r--r-- | modules/default.nix | 2 | ||||
| -rw-r--r-- | pkgs/all-packages.nix | 10 | ||||
| -rw-r--r-- | pkgs/default.nix | 19 |
11 files changed, 185 insertions, 301 deletions
diff --git a/.github/workflows/update-inputs.yaml b/.github/workflows/update-inputs.yaml deleted file mode 100644 index dc6b5f1..0000000 --- a/.github/workflows/update-inputs.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: update inputs - -on: - #schedule: - # # run every saturday - # - cron: "0 0 * * 6" - workflow_dispatch: - -permissions: - contents: write - pull-requests: write - -jobs: - update-lock: - runs-on: ubuntu-latest - - steps: - - name: checkout repo - uses: actions/checkout@v4 - - - uses: cachix/install-nix-action@v23 - with: - github_access_token: ${{ github.token }} - - - uses: DeterminateSystems/update-flake-lock@v20 - id: update - with: - commit-msg: "flake: update inputs" - pr-title: "flake: update all inputs" - nix-options: "--accept-flake-config" - token: ${{ github.token }} - - - name: auto-merge pull request - run: gh pr merge --auto --rebase "$PR_ID" - env: - GITHUB_TOKEN: ${{ github.token }} - PR_ID: ${{ steps.update.outputs.pull-request-number }} diff --git a/.github/workflows/update-lock.yaml b/.github/workflows/update-lock.yaml new file mode 100644 index 0000000..9e3301d --- /dev/null +++ b/.github/workflows/update-lock.yaml @@ -0,0 +1,34 @@ +name: update flake lock + +on: + schedule: + # run every saturday + - cron: "0 0 * * 6" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + + - name: update lockfile + uses: DeterminateSystems/update-flake-lock@v20 + id: update + with: + commit-msg: "flake: update inputs" + pr-title: "flake: update inputs" + token: ${{ github.token }} + + - name: enable auto-merge + shell: bash + run: gh pr merge --auto --rebase "$PR_ID" + env: + GITHUB_TOKEN: ${{ github.token }} + PR_ID: ${{ steps.update.outputs.pull-request-number }} @@ -1,57 +1,93 @@ # nix-exprs [](https://garnix.io) -[](https://hercules-ci.com/) ## how to use -### enable binary cache +### enabling the binary cache -linux packages are built with [hercules-ci](https://hercules-ci.com/), while packages for apple silicon -are built with [garnix](https://garnix.io/). both have binary caches, however different ones; you can use -garnix's by following the instructions [here](https://garnix.io/docs/caching), and the cachix cache for -hercules-ci by following the instructions [here](https://app.cachix.org/cache/getchoo#pull). i would also recommend -[donating](https://opencollective.com/garnix_io) to garnix if you can! - -example: +all packages are built with [garnix](https://garnix.io/), and cached on their servers. you can use this +yourself by following the instructions [here](https://garnix.io/docs/caching). i would also recommend +[donating](https://opencollective.com/garnix_io) if you can! <details> -<summary>nixos configuration</summary> +<summary>example</summary> ```nix { nix.settings = { - trusted-substituters = [ - "https://cache.garnix.io" - "https://getchoo.cachix.org" - ]; - - trusted-public-keys = [ - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" - "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" - ]; - } + trusted-substituters = ["https://cache.garnix.io"]; + + trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="]; + }; } ``` </details> +### installing packages (flake) + +you can add this repository as an input, and optionally override the nixpkgs input to build against +your own revision. from there, you can use packages as an overlay or install them directly + <details> -<summary>using `cachix` on linux</summary> +<summary>with the overlay</summary> -```bash -nix run nixpkgs#cachix -- use getchoo +```nix +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + darwin = { + url = "github:LnL7/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + getchoo = { + url = "github:getchoo/nix-exprs"; + # this will break reproducibility, but lower the instances of nixpkgs + # in flake.lock + # inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + getchoo, + ... + }: let + getchooModule = { + nixpkgs.overlays = [getchoo.overlays.default]; + environment.systemPackages = [pkgs.treefetch]; + }; + in { + nixosConfigurations.hostname = nixpkgs.lib.nixosSystem { + modules = [getchooModule]; + }; + + darwinConfigurations.hostname = darwin.lib.darwinSystem { + modules = [getchooModule]; + }; + }; +} ``` </details> -### flake configuration +<details> +<summary>directly</summary> ```nix { inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + darwin = { + url = "github:LnL7/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; getchoo = { url = "github:getchoo/nix-exprs"; + # this will break reproducibility, but lower the instances of nixpkgs + # in flake.lock + # inputs.nixpkgs.follows = "nixpkgs"; }; }; @@ -59,46 +95,71 @@ nix run nixpkgs#cachix -- use getchoo nixpkgs, getchoo, ... - }: { + }: let + getchooModule = ({pkgs, ...}: let + inherit (pkgs.stdenv.hostPlatform) system; + in { + environment.systemPackages = [getchoo.packages.${system}.treefetch]; + }); + in { nixosConfigurations.hostname = nixpkgs.lib.nixosSystem { - modules = [ - { - nixpkgs.overlays = [getchoo.overlays.default]; - environment.systemPackages = with pkgs; [ - treefetch - ]; - } - ]; + modules = [getchooModule]; + }; + + darwinConfigurations.hostname = darwin.lib.darwinSystem { + modules = [getchooModule]; }; }; } ``` -### nix channels +</details> -#### adding the channel +### installing packages (without flakes) -```bash -nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo -nix-channel --update +this repository uses [flake-compat](https://github.com/edolstra/flake-compat) to allow for non-flake users to +import a channel or the `default.nix` to access the flake's outputs. + +<details> +<summary>with the overlay</summary> + +```nix +{pkgs, ...}: let + # install with `nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo` + getchoo = import <getchoo>; + + # or use `fetchTarball` + # getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz"); +in { + nixpkgs.overlays = [getchoo.overlays.default]; + environment.systemPackages = [pkgs.treefetch]; +} ``` -#### usage +</details> + +<details> +<summary>directly</summary> ```nix {pkgs, ...}: let - getchoo = import <getchoo>; + inherit (pkgs.stdenv.hostPlatform) system; + + # install with `nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo` + getchoo = import <getchoo>; + + # or use `fetchTarball` + # getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz"); in { - nixpkgs.overlays = [getchoo.overlays.default]; - environment.systemPackages = with pkgs; [ - treefetch - ]; + environment.systemPackages = [getchoo.packages.${system}.treefetch]; } ``` -### cli support +</details> + +### ad-hoc installation -this overlay can also be used in the base nix package manager :) +this flake can also be used in the base nix package manager :) > **Note** > for nixos/nix-darwin users, `nixpkgs.overlays` does not configure @@ -108,29 +169,40 @@ this overlay can also be used in the base nix package manager :) the best way to make this overlay available for you is to add it to your flake registry or `~/.config/nixpkgs/overlays.nix`. -#### flake registry +<details> +<summary>flake registry</summary> this is the preferred way to use this overlay in the cli, as it allows for full reproducibility with the flake. -to use this overlay with commands like `nix build/run/shell`, you can +to use this overlay with commands like `nix build/run/shell/profile`, you can add it to your flake registry: ```shell nix registry add getchoo github:getchoo/nix-exprs -nix run getchoo#treefetch +nix profile install getchoo#treefetch ``` -#### overlays.nix +</details> + +<details> +<summary>overlays.nix</summary> for those who don't want to use this flake's revision of nixpkgs, or do not use flakes, you can also add it as an overlay. -[add the channel](#adding-the-channel) to your nix profile, then place -this in `~/.config/nixpkgs/overlays.nix` (or a nix file in `~/.config/nixpkgs/overlays/`): +first, add the channel for this repository with + +```sh +nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo +``` + +then in `~/.config/nixpkgs/overlays.nix`: ```nix let getchoo = import <getchoo>; in [getchoo.overlays.default] ``` + +</details> diff --git a/default.nix b/default.nix index c7d0c26..7d52616 100644 --- a/default.nix +++ b/default.nix @@ -1,14 +1,6 @@ -( - import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - {src = ./.;} -) +(import + (fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9.tar.gz"; + hash = "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8="; + } {src = ./.;})) .defaultNix @@ -1,102 +1,5 @@ { "nodes": { - "effects": { - "inputs": { - "flake-parts": "flake-parts", - "hercules-ci-agent": [ - "hercules-ci-agent" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1689397210, - "narHash": "sha256-fVxZnqxMbsDkB4GzGAs/B41K0wt/e+B/fLxmTFF/S20=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "0a63bfa3f00a3775ea3a6722b247880f1ffe91ce", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1688466019, - "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "haskell-flake": { - "locked": { - "lastModified": 1684780604, - "narHash": "sha256-2uMZsewmRn7rRtAnnQNw1lj0uZBMh4m6Cs/7dV5YF08=", - "owner": "srid", - "repo": "haskell-flake", - "rev": "74210fa80a49f1b6f67223debdbf1494596ff9f2", - "type": "github" - }, - "original": { - "owner": "srid", - "ref": "0.3.0", - "repo": "haskell-flake", - "type": "github" - } - }, - "hercules-ci-agent": { - "inputs": { - "flake-parts": [ - "parts" - ], - "haskell-flake": "haskell-flake", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1693397971, - "narHash": "sha256-P5PQ8KzK/SXvEsw+AzG7OBUgnGhuUzKETNHhqVokc+0=", - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "rev": "344b8b1079731a8c1e144119174f684fb492e03a", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1693565476, @@ -112,24 +15,6 @@ "type": "indirect" } }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1688049487, - "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "parts": { "inputs": { "nixpkgs-lib": [ @@ -152,9 +37,6 @@ }, "root": { "inputs": { - "effects": "effects", - "flake-compat": "flake-compat", - "hercules-ci-agent": "hercules-ci-agent", "nixpkgs": "nixpkgs", "parts": "parts" } @@ -2,40 +2,17 @@ description = "getchoo's nix expressions"; nixConfig = { - extra-substituters = [ - "https://getchoo.cachix.org" - "https://cache.garnix.io" - ]; - extra-trusted-public-keys = [ - "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" - ]; + extra-substituters = ["https://cache.garnix.io"]; + extra-trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="]; }; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - effects = { - url = "github:hercules-ci/hercules-ci-effects"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.hercules-ci-agent.follows = "hercules-ci-agent"; - }; - parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - - hercules-ci-agent = { - url = "github:hercules-ci/hercules-ci-agent"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-parts.follows = "parts"; - }; }; outputs = {parts, ...} @ inputs: @@ -44,7 +21,6 @@ ./pkgs ./modules ./templates - ./hci.nix ]; systems = [ @@ -54,8 +30,6 @@ "aarch64-darwin" ]; - perSystem = {pkgs, ...}: { - formatter = pkgs.alejandra; - }; + perSystem = {pkgs, ...}: {formatter = pkgs.alejandra;}; }; } diff --git a/garnix.yaml b/garnix.yaml index f215263..00227d6 100644 --- a/garnix.yaml +++ b/garnix.yaml @@ -1,5 +1,7 @@ builds: exclude: [] include: + - "packages.x86_64-linux.*" + - "packages.aarch64-linux.*" - "packages.aarch64-darwin.modrinth-app" - "packages.aarch64-darwin.modrinth-app-unwrapped" diff --git a/hci.nix b/hci.nix deleted file mode 100644 index a9688cd..0000000 --- a/hci.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - inputs, - self, - ... -}: { - imports = [ - inputs.effects.flakeModule - ]; - - hercules-ci.flake-update = { - enable = true; - autoMergeMethod = "rebase"; - - flakes = { - ".".commitSummary = "flake: update inputs"; - }; - - when = { - minute = 0; - hour = [0]; - dayOfWeek = ["Sun"]; - }; - }; - - herculesCI = { - config, - lib, - ... - }: let - findCompatible = lib.filterAttrs (s: _: builtins.elem s config.ciSystems); - in { - ciSystems = ["x86_64-linux" "aarch64-linux"]; - - onPush.default.outputs = lib.mkForce { - packages = findCompatible self.packages; - }; - }; -} diff --git a/modules/default.nix b/modules/default.nix index 9b68c34..e869905 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,4 @@ -_: { +{ flake = { flakeModules = { default = import ./flake; diff --git a/pkgs/all-packages.nix b/pkgs/all-packages.nix index 1709f66..38f95f0 100644 --- a/pkgs/all-packages.nix +++ b/pkgs/all-packages.nix @@ -17,12 +17,14 @@ in { nixgc = callPackage ./nixgc.nix {}; - modrinth-app-unwrapped = final.callPackage ./modrinth-app { - inherit (prev.nodePackages) pnpm; - inherit (prev.darwin.apple_sdk.frameworks) CoreServices Security WebKit; + modrinth-app-unwrapped = callPackage ./modrinth-app { + inherit (final.nodePackages) pnpm; + inherit (final.darwin.apple_sdk.frameworks) CoreServices Security WebKit; }; - modrinth-app = final.callPackage ./modrinth-app/wrapper.nix {}; + modrinth-app = callPackage ./modrinth-app/wrapper.nix { + inherit (final) modrinth-app-unwrapped; + }; treefetch = callPackage ./treefetch.nix {}; diff --git a/pkgs/default.nix b/pkgs/default.nix index 399a8fd..e66c1d3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,4 @@ -_: { +{self, ...}: { perSystem = { lib, pkgs, @@ -7,15 +7,16 @@ _: { }: { packages = let inherit (builtins) elem; - inherit (lib) filterAttrs makeScope; - inherit (pkgs) newScope; + inherit (lib) filterAttrs fix; - p = let - packages = makeScope newScope (final: import ./all-packages.nix final pkgs); - in - filterAttrs (_: v: - elem system (v.meta.platforms or []) && !(v.meta.broken or false)) - packages; + unfiltered = fix ( + final: + self.overlays.default (final // {inherit (pkgs) nodePackages darwin;}) pkgs + ); + + p = filterAttrs (_: v: + elem system (v.meta.platforms or []) && !(v.meta.broken or false)) + unfiltered; in p // {default = p.treefetch;}; }; |
