diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4c6160f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake ./dev diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eb4bc37..be0d189 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,12 +9,14 @@ jobs: checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v18 + - uses: actions/checkout@v3 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + - uses: cachix/cachix-action@v12 with: - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + name: srid + - name: Build 🔨 + run: nix run github:srid/nixci - name: Test example id: example run: | @@ -28,8 +30,4 @@ jobs: cd $TEMP_DIR nix flake init -t $FLAKE nix develop --override-input mission-control path:${FLAKE} -c , fmt - - name: Flake checks 🧪 - run: | - # Because 'nix flake check' is not system-aware - # See https://srid.ca/haskell-template/checks - nix run nixpkgs#sd 'systems = nixpkgs.lib.systems.flakeExposed' 'systems = [ "x86_64-linux" ]' flake.nix + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/dev/flake.lock b/dev/flake.lock new file mode 100644 index 0000000..04434a7 --- /dev/null +++ b/dev/flake.lock @@ -0,0 +1,131 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1685662779, + "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1680964220, + "narHash": "sha256-dIdTYcf+KW9a4pKHsEbddvLVSfR1yiAJynzg2x0nfWg=", + "owner": "srid", + "repo": "flake-root", + "rev": "f1c0b93d05bdbea6c011136ba1a135c80c5b326c", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, + "mission-control": { + "locked": { + "lastModified": 1683658484, + "narHash": "sha256-JkGnWyYZxOnyOhztrxLSqaod6+O/3rRypq0dAqA/zn0=", + "owner": "Platonic-Systems", + "repo": "mission-control", + "rev": "a0c93bd764a3c25e6999397e9f5f119c1b124e38", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "mission-control", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1685564631, + "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1680945546, + "narHash": "sha256-8FuaH5t/aVi/pR1XxnF0qi4WwMYC+YxlfdsA0V+TEuQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d9f759f2ea8d265d974a6e1259bd510ac5844c5d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "flake-root": "flake-root", + "mission-control": "mission-control", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1689620039, + "narHash": "sha256-BtNwghr05z7k5YMdq+6nbue+nEalvDepuA7qdQMAKoQ=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "719c2977f958c41fa60a928e2fbc50af14844114", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dev/flake.nix b/dev/flake.nix new file mode 100644 index 0000000..1d6a222 --- /dev/null +++ b/dev/flake.nix @@ -0,0 +1,39 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + flake-root.url = "github:srid/flake-root"; + mission-control.url = "github:Platonic-Systems/mission-control"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.flake-root.flakeModule + inputs.mission-control.flakeModule + inputs.treefmt-nix.flakeModule + ]; + perSystem = { pkgs, lib, config, ... }: { + treefmt = { + projectRootFile = "flake.nix"; + programs = { + nixpkgs-fmt.enable = true; + }; + }; + mission-control.scripts = { + fmt = { + description = "Format all Nix files"; + exec = config.treefmt.build.wrapper; + }; + }; + devShells.default = pkgs.mkShell { + # cf. https://zero-to-flakes.com/haskell-flake/devshell#composing-devshells + inputsFrom = [ + config.mission-control.devShell + config.treefmt.build.devShell + ]; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index 46dd071..3f5555e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,22 @@ { description = "A `flake-parts` module for your Nix devshell scripts"; - outputs = { self, ... }: { + outputs = { ... }: { flakeModule = ./nix/flake-module.nix; templates.default = { description = "Example flake using mission-control to provide scripts"; path = builtins.path { path = ./example; filter = path: type: baseNameOf path == "flake.nix"; }; }; + + # Config for https://github.com/srid/nixci + # To run this, `nix run github:srid/nixci` + nixci = let overrideInputs = { "mission-control" = ./.; }; in { + example = { + inherit overrideInputs; + dir = "./example"; + }; + dev = { + dir = "./dev"; + }; + }; }; }