From 7f20ccd032bf5111d643ee925929758822754e65 Mon Sep 17 00:00:00 2001 From: osbm Date: Tue, 21 Oct 2025 11:53:44 +0300 Subject: [PATCH 1/2] add github actions ci --- .github/workflows/ci.yml | 175 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dcaf978 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,175 @@ +name: Nix flake checks (per-template) + +on: + push: + pull_request: + types: [opened, synchronize, reopened] + schedule: + # once a day (midnight UTC) + - cron: '0 0 * * *' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: nix-flake-check-${{ github.ref }} + cancel-in-progress: true + +jobs: + prepare: + name: Prepare matrix of templates + runs-on: ubuntu-latest + outputs: + dirs: ${{ steps.set-matrix.outputs.dirs }} + has_templates: ${{ steps.set-matrix.outputs.has_templates }} + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Detect changed template directories + id: set-matrix + shell: bash + run: | + set -euo pipefail + + # Find all top-level directories that contain a flake.nix + mapfile -t ALL_TEMPLATES < <(find . -maxdepth 2 -name flake.nix -print0 | xargs -0 -n1 dirname | sed 's|^\./||' | grep -v '^\.$' || true) + # Ensure unique and sorted + if [ ${#ALL_TEMPLATES[@]} -gt 0 ]; then + ALL_TEMPLATES=( $(printf "%s\n" "${ALL_TEMPLATES[@]}" | sort -u) ) + fi + echo "All templates: ${ALL_TEMPLATES[*]}" >&2 + + # If scheduled run or manual dispatch, operate on all templates + if [ "${GITHUB_EVENT_NAME}" = "schedule" ] || [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then + # For manual runs, allow an optional `dirs` input (comma/space/newline-separated) to limit templates. + if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then + if jq -e '.inputs and .inputs.dirs' "$GITHUB_EVENT_PATH" >/dev/null 2>&1; then + INPUT_DIRS=$(jq -r '.inputs.dirs // ""' "$GITHUB_EVENT_PATH") + if [ -n "$INPUT_DIRS" ]; then + dirs_json=$(printf "%s\n" "$INPUT_DIRS" | tr ',' '\n' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | jq -R -s -c 'split("\n")[:-1]') + echo "dirs=$dirs_json" >> $GITHUB_OUTPUT + echo "has_templates=true" >> $GITHUB_OUTPUT + exit 0 + fi + fi + fi + + dirs_json=$(printf "%s\n" "${ALL_TEMPLATES[@]}" | jq -R -s -c 'split("\n")[:-1]') + echo "dirs=$dirs_json" >> $GITHUB_OUTPUT + echo "has_templates=true" >> $GITHUB_OUTPUT + exit 0 + fi + + # Determine base/head SHAs + if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then + BASE_SHA=$(jq -r .pull_request.base.sha "$GITHUB_EVENT_PATH") + HEAD_SHA=$(jq -r .pull_request.head.sha "$GITHUB_EVENT_PATH") + else + BASE_SHA=$(jq -r .before "$GITHUB_EVENT_PATH") + HEAD_SHA=$GITHUB_SHA + fi + + echo "Base: $BASE_SHA Head: $HEAD_SHA" >&2 + + # If base is all zeros (new branch), compare against default branch + if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then + DEFAULT_BRANCH=$(jq -r .repository.default_branch "$GITHUB_EVENT_PATH") + git fetch origin "$DEFAULT_BRANCH" --depth=1 || true + BASE_SHA=$(git rev-parse origin/"$DEFAULT_BRANCH") + fi + + # Ensure refs are available for diff + git fetch --no-tags --prune --depth=1 origin || true + + CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" || true) + echo "Changed files:\n$CHANGED_FILES" >&2 + + # If the repo-level flake changed, run all templates + if printf "%s\n" "$CHANGED_FILES" | grep -qx "flake.nix"; then + echo "Root flake.nix changed: running all templates" >&2 + dirs_json=$(printf "%s\n" "${ALL_TEMPLATES[@]}" | jq -R -s -c 'split("\n")[:-1]') + echo "dirs=$dirs_json" >> $GITHUB_OUTPUT + echo "has_templates=true" >> $GITHUB_OUTPUT + exit 0 + fi + + # Map changed files to top-level dirs and keep only those that are templates + mapfile -t TOP_DIRS < <(printf "%s\n" "$CHANGED_FILES" | awk -F/ '{print $1}' | sort -u | sed '/^\s*$/d' || true) + + SELECTED=() + for d in "${TOP_DIRS[@]:-}"; do + if [ -n "$d" ] && [ -d "$d" ] && [ -f "$d/flake.nix" ]; then + SELECTED+=("$d") + fi + done + + # If nothing selected, return empty + if [ ${#SELECTED[@]} -eq 0 ]; then + echo "dirs=[]" >> $GITHUB_OUTPUT + echo "has_templates=false" >> $GITHUB_OUTPUT + exit 0 + fi + + # Build JSON array of selected template dirs + dirs_json=$(printf "%s\n" "${SELECTED[@]}" | jq -R -s -c 'split("\n")[:-1]') + echo "Detected templates: $dirs_json" >&2 + echo "dirs=$dirs_json" >> $GITHUB_OUTPUT + echo "has_templates=true" >> $GITHUB_OUTPUT + + check: + name: Run nix flake check and show + needs: prepare + if: ${{ needs.prepare.outputs.has_templates == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 4 + matrix: + dir: ${{ fromJson(needs.prepare.outputs.dirs) }} + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install Nix (non-daemon) and enable flakes + uses: cachix/install-nix-action@v31.8.1 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Run nix flake check + shell: bash + run: | + echo "=== nix flake check -- ${{ matrix.dir }} ===" + cd "${{ matrix.dir }}" + # run checks; will fail the job if tests fail + nix flake check + + - name: Run nix flake show + shell: bash + run: | + echo "=== nix flake show -- ${{ matrix.dir }} ===" + cd "${{ matrix.dir }}" + nix flake show + + + lint: + name: Lint all nix file with treefmt + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install Nix (non-daemon) and enable flakes + uses: cachix/install-nix-action@v31.8.1 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Run nixfmt + run: | + nix run nixpkgs#nixfmt-tree -- --ci From d15c00b24779263f8add3e2969a8219d9f53a131 Mon Sep 17 00:00:00 2001 From: osbm Date: Tue, 21 Oct 2025 12:45:30 +0300 Subject: [PATCH 2/2] format with nixfmt --- bash-hello/flake.nix | 114 ++++++------ c-hello/flake.nix | 122 +++++++------ compat/default.nix | 2 +- compat/shell.nix | 2 +- dotnet/flake.nix | 72 +++++--- dotnet/nix/deps.nix | 3 +- flake.nix | 314 +++++++++++++++++---------------- full/flake.nix | 148 +++++++++------- go-hello/flake.nix | 29 ++- haskell-flake/flake.nix | 90 +++++----- haskell-hello/flake.nix | 48 +++-- haskell.nix/flake.nix | 45 +++-- haskell.nix/nix/hix.nix | 20 ++- hercules-ci/ci.nix | 7 +- hercules-ci/flake-compat.nix | 7 +- hercules-ci/flake.nix | 16 +- latexmk/default.nix | 5 +- latexmk/flake.nix | 13 +- pandoc-xelatex/flake.nix | 51 +++--- python/flake.nix | 52 ++++-- ruby/default.nix | 14 +- ruby/flake.nix | 39 ++-- ruby/gemset.nix | 146 ++++++++------- ruby/shell.nix | 14 +- rust-web-server/flake.nix | 168 ++++++++++-------- rust/default.nix | 14 +- rust/flake.nix | 27 ++- rust/shell.nix | 14 +- simple-container/flake.nix | 45 ++--- trivial/flake.nix | 10 +- typescript/pnpm-p5js/flake.nix | 11 +- typescript/pnpm/flake.nix | 11 +- utils-generic/flake.nix | 27 +-- 33 files changed, 985 insertions(+), 715 deletions(-) diff --git a/bash-hello/flake.nix b/bash-hello/flake.nix index 1c2045b..86a078d 100644 --- a/bash-hello/flake.nix +++ b/bash-hello/flake.nix @@ -4,7 +4,8 @@ # Nixpkgs / NixOS version to use. inputs.nixpkgs.url = "nixpkgs/nixos-21.05"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let # to work with older version of flakes @@ -14,13 +15,24 @@ version = builtins.substring 0 8 lastModifiedDate; # System types to support. - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; # Nixpkgs instantiated for supported system types. - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; }); + nixpkgsFor = forAllSystems ( + system: + import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + } + ); in @@ -29,13 +41,14 @@ # A Nixpkgs overlay. overlay = final: prev: { - hello = with final; stdenv.mkDerivation rec { - name = "hello-${version}"; + hello = + with final; + stdenv.mkDerivation rec { + name = "hello-${version}"; - unpackPhase = ":"; + unpackPhase = ":"; - buildPhase = - '' + buildPhase = '' cat > hello <` - apps.x86_64-linux.hello = { - type = "app"; - program = c-hello.packages.x86_64-linux.hello; + outputs = + all@{ + self, + c-hello, + rust-web-server, + nixpkgs, + nix-bundle, + ... + }: + { + + # Utilized by `nix flake check` + checks.x86_64-linux.test = c-hello.checks.x86_64-linux.test; + + # Utilized by `nix build .` + defaultPackage.x86_64-linux = c-hello.defaultPackage.x86_64-linux; + + # Utilized by `nix build` + packages.x86_64-linux.hello = c-hello.packages.x86_64-linux.hello; + + # Utilized by `nix run .#` + apps.x86_64-linux.hello = { + type = "app"; + program = c-hello.packages.x86_64-linux.hello; + }; + + # Utilized by `nix bundle -- .#` (should be a .drv input, not program path?) + bundlers.x86_64-linux.example = nix-bundle.bundlers.x86_64-linux.toArx; + + # Utilized by `nix bundle -- .#` + defaultBundler.x86_64-linux = self.bundlers.x86_64-linux.example; + + # Utilized by `nix run . -- ` + defaultApp.x86_64-linux = self.apps.x86_64-linux.hello; + + # Utilized for nixpkgs packages, also utilized by `nix build .#` + legacyPackages.x86_64-linux.hello = c-hello.defaultPackage.x86_64-linux; + + # Default overlay, for use in dependent flakes + overlay = final: prev: { }; + + # # Same idea as overlay but a list or attrset of them. + overlays = { + exampleOverlay = self.overlay; + }; + + # Default module, for use in dependent flakes. Deprecated, use nixosModules.default instead. + nixosModule = + { config, ... }: + { + options = { }; + config = { }; + }; + + # Same idea as nixosModule but a list or attrset of them. + nixosModules = { + exampleModule = self.nixosModule; + }; + + # Used with `nixos-rebuild --flake .#` + # nixosConfigurations."".config.system.build.toplevel must be a derivation + nixosConfigurations.example = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ { boot.isContainer = true; } ]; + }; + + # Utilized by `nix develop` + devShell.x86_64-linux = rust-web-server.devShell.x86_64-linux; + + # Utilized by `nix develop .#` + devShells.x86_64-linux.example = self.devShell.x86_64-linux; + + # Utilized by Hydra build jobs + hydraJobs.example.x86_64-linux = self.defaultPackage.x86_64-linux; + + # Utilized by `nix flake init -t ` + defaultTemplate = { + path = c-hello; + description = "template description"; + }; + + # Utilized by `nix flake init -t #` + templates.example = self.defaultTemplate; }; - - # Utilized by `nix bundle -- .#` (should be a .drv input, not program path?) - bundlers.x86_64-linux.example = nix-bundle.bundlers.x86_64-linux.toArx; - - # Utilized by `nix bundle -- .#` - defaultBundler.x86_64-linux = self.bundlers.x86_64-linux.example; - - # Utilized by `nix run . -- ` - defaultApp.x86_64-linux = self.apps.x86_64-linux.hello; - - # Utilized for nixpkgs packages, also utilized by `nix build .#` - legacyPackages.x86_64-linux.hello = c-hello.defaultPackage.x86_64-linux; - - # Default overlay, for use in dependent flakes - overlay = final: prev: { }; - - # # Same idea as overlay but a list or attrset of them. - overlays = { exampleOverlay = self.overlay; }; - - # Default module, for use in dependent flakes. Deprecated, use nixosModules.default instead. - nixosModule = { config, ... }: { options = {}; config = {}; }; - - # Same idea as nixosModule but a list or attrset of them. - nixosModules = { exampleModule = self.nixosModule; }; - - # Used with `nixos-rebuild --flake .#` - # nixosConfigurations."".config.system.build.toplevel must be a derivation - nixosConfigurations.example = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [{boot.isContainer=true;}] ; - }; - - # Utilized by `nix develop` - devShell.x86_64-linux = rust-web-server.devShell.x86_64-linux; - - # Utilized by `nix develop .#` - devShells.x86_64-linux.example = self.devShell.x86_64-linux; - - # Utilized by Hydra build jobs - hydraJobs.example.x86_64-linux = self.defaultPackage.x86_64-linux; - - # Utilized by `nix flake init -t ` - defaultTemplate = { - path = c-hello; - description = "template description"; - }; - - # Utilized by `nix flake init -t #` - templates.example = self.defaultTemplate; - }; } diff --git a/go-hello/flake.nix b/go-hello/flake.nix index f76ae18..c04f887 100644 --- a/go-hello/flake.nix +++ b/go-hello/flake.nix @@ -4,7 +4,8 @@ # Nixpkgs / NixOS version to use. inputs.nixpkgs.url = "nixpkgs/nixos-21.11"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let # to work with older version of flakes @@ -14,7 +15,12 @@ version = builtins.substring 0 8 lastModifiedDate; # System types to support. - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; @@ -26,7 +32,8 @@ { # Provide some binary packages for selected system types. - packages = forAllSystems (system: + packages = forAllSystems ( + system: let pkgs = nixpkgsFor.${system}; in @@ -50,18 +57,26 @@ vendorHash = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="; }; - }); + } + ); # Add dependencies that are only needed for development - devShells = forAllSystems (system: + devShells = forAllSystems ( + system: let pkgs = nixpkgsFor.${system}; in { default = pkgs.mkShell { - buildInputs = with pkgs; [ go gopls gotools go-tools ]; + buildInputs = with pkgs; [ + go + gopls + gotools + go-tools + ]; }; - }); + } + ); # The default package for 'nix build'. This makes sense if the # flake provides only one package or there is a clear "main" diff --git a/haskell-flake/flake.nix b/haskell-flake/flake.nix index 6b7834f..84623a5 100644 --- a/haskell-flake/flake.nix +++ b/haskell-flake/flake.nix @@ -4,54 +4,62 @@ flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; }; - outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + outputs = + inputs@{ + self, + nixpkgs, + flake-parts, + ... + }: flake-parts.lib.mkFlake { inherit inputs; } { systems = nixpkgs.lib.systems.flakeExposed; imports = [ inputs.haskell-flake.flakeModule ]; - perSystem = { self', pkgs, ... }: { + perSystem = + { self', pkgs, ... }: + { - # Typically, you just want a single project named "default". But - # multiple projects are also possible, each using different GHC version. - haskellProjects.default = { - # The base package set representing a specific GHC version. - # By default, this is pkgs.haskellPackages. - # You may also create your own. See https://zero-to-flakes.com/haskell-flake/package-set - # basePackages = pkgs.haskellPackages; + # Typically, you just want a single project named "default". But + # multiple projects are also possible, each using different GHC version. + haskellProjects.default = { + # The base package set representing a specific GHC version. + # By default, this is pkgs.haskellPackages. + # You may also create your own. See https://zero-to-flakes.com/haskell-flake/package-set + # basePackages = pkgs.haskellPackages; - # Extra package information. See https://zero-to-flakes.com/haskell-flake/dependency - # - # Note that local packages are automatically included in `packages` - # (defined by `defaults.packages` option). - # - # packages = { - # aeson.source = "1.5.0.0"; # Hackage version override - # shower.source = inputs.shower; - # }; - # settings = { - # aeson = { - # check = false; - # }; - # relude = { - # haddock = false; - # broken = false; - # }; - # }; + # Extra package information. See https://zero-to-flakes.com/haskell-flake/dependency + # + # Note that local packages are automatically included in `packages` + # (defined by `defaults.packages` option). + # + # packages = { + # aeson.source = "1.5.0.0"; # Hackage version override + # shower.source = inputs.shower; + # }; + # settings = { + # aeson = { + # check = false; + # }; + # relude = { + # haddock = false; + # broken = false; + # }; + # }; - # devShell = { - # # Enabled by default - # enable = true; - # - # # Programs you want to make available in the shell. - # # Default programs can be disabled by setting to 'null' - # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; - # - # hlsCheck.enable = true; - # }; - }; + # devShell = { + # # Enabled by default + # enable = true; + # + # # Programs you want to make available in the shell. + # # Default programs can be disabled by setting to 'null' + # tools = hp: { fourmolu = hp.fourmolu; ghcid = null; }; + # + # hlsCheck.enable = true; + # }; + }; - # haskell-flake doesn't set the default package, but you can do it here. - packages.default = self'.packages.example; - }; + # haskell-flake doesn't set the default package, but you can do it here. + packages.default = self'.packages.example; + }; }; } diff --git a/haskell-hello/flake.nix b/haskell-hello/flake.nix index 0b9e98f..d81c7e5 100644 --- a/haskell-hello/flake.nix +++ b/haskell-hello/flake.nix @@ -2,35 +2,49 @@ # inspired by: https://serokell.io/blog/practical-nix-flakes#packaging-existing-applications description = "A Hello World in Haskell with a dependency and a devShell"; inputs.nixpkgs.url = "nixpkgs"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let - supportedSystems = [ "x86_64-linux" "x86_64-darwin" ]; + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + ]; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); - nixpkgsFor = forAllSystems (system: import nixpkgs { - inherit system; - overlays = [ self.overlay ]; - }); + nixpkgsFor = forAllSystems ( + system: + import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + } + ); in { - overlay = (final: prev: { - haskell-hello = final.haskellPackages.callCabal2nix "haskell-hello" ./. {}; - }); + overlay = ( + final: prev: { + haskell-hello = final.haskellPackages.callCabal2nix "haskell-hello" ./. { }; + } + ); packages = forAllSystems (system: { - haskell-hello = nixpkgsFor.${system}.haskell-hello; + haskell-hello = nixpkgsFor.${system}.haskell-hello; }); defaultPackage = forAllSystems (system: self.packages.${system}.haskell-hello); checks = self.packages; - devShell = forAllSystems (system: let haskellPackages = nixpkgsFor.${system}.haskellPackages; - in haskellPackages.shellFor { - packages = p: [self.packages.${system}.haskell-hello]; + devShell = forAllSystems ( + system: + let + haskellPackages = nixpkgsFor.${system}.haskellPackages; + in + haskellPackages.shellFor { + packages = p: [ self.packages.${system}.haskell-hello ]; withHoogle = true; buildInputs = with haskellPackages; [ haskell-language-server ghcid cabal-install ]; - # Change the prompt to show that you are in a devShell - shellHook = "export PS1='\\e[1;34mdev > \\e[0m'"; - }); - }; + # Change the prompt to show that you are in a devShell + shellHook = "export PS1='\\e[1;34mdev > \\e[0m'"; + } + ); + }; } diff --git a/haskell.nix/flake.nix b/haskell.nix/flake.nix index 4579470..600e0fc 100644 --- a/haskell.nix/flake.nix +++ b/haskell.nix/flake.nix @@ -3,7 +3,13 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, flake-utils, haskellNix }: + outputs = + { + self, + nixpkgs, + flake-utils, + haskellNix, + }: let supportedSystems = [ "x86_64-linux" @@ -12,32 +18,41 @@ "aarch64-darwin" ]; in - flake-utils.lib.eachSystem supportedSystems (system: + flake-utils.lib.eachSystem supportedSystems ( + system: let - overlays = [ haskellNix.overlay + overlays = [ + haskellNix.overlay (final: prev: { - hixProject = - final.haskell-nix.hix.project { - src = ./.; - evalSystem = "x86_64-linux"; - }; + hixProject = final.haskell-nix.hix.project { + src = ./.; + evalSystem = "x86_64-linux"; + }; }) ]; - pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; - flake = pkgs.hixProject.flake {}; - in flake // { + pkgs = import nixpkgs { + inherit system overlays; + inherit (haskellNix) config; + }; + flake = pkgs.hixProject.flake { }; + in + flake + // { legacyPackages = pkgs; - packages = flake.packages // { default = flake.packages."hello:exe:hello"; }; - }); + packages = flake.packages // { + default = flake.packages."hello:exe:hello"; + }; + } + ); # --- Flake Local Nix Configuration ---------------------------- nixConfig = { # This sets the flake to use the IOG nix cache. # Nix should ask for permission before using it, # but remove it here if you do not want it to. - extra-substituters = ["https://cache.iog.io"]; - extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; + extra-substituters = [ "https://cache.iog.io" ]; + extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; allow-import-from-derivation = "true"; }; } diff --git a/haskell.nix/nix/hix.nix b/haskell.nix/nix/hix.nix index e80be0b..724fbcc 100644 --- a/haskell.nix/nix/hix.nix +++ b/haskell.nix/nix/hix.nix @@ -1,13 +1,19 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ # name = "project-name"; compiler-nix-name = "ghc926"; # Version of GHC to use - crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([ - p.mingwW64 - # p.ghcjs # TODO GHCJS support for GHC 9.2 - ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ - p.musl64 - ]); + crossPlatforms = + p: + pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ( + [ + p.mingwW64 + # p.ghcjs # TODO GHCJS support for GHC 9.2 + ] + ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + p.musl64 + ] + ); # Tools to include in the development shell shell.tools.cabal = "latest"; diff --git a/hercules-ci/ci.nix b/hercules-ci/ci.nix index 1f71eca..0eec73d 100644 --- a/hercules-ci/ci.nix +++ b/hercules-ci/ci.nix @@ -1,3 +1,4 @@ -if builtins?getFlake -then (builtins.getFlake (toString ./.)).ciNix -else (import ./flake-compat.nix).defaultNix.ciNix +if builtins ? getFlake then + (builtins.getFlake (toString ./.)).ciNix +else + (import ./flake-compat.nix).defaultNix.ciNix diff --git a/hercules-ci/flake-compat.nix b/hercules-ci/flake-compat.nix index dab420b..200f6b5 100644 --- a/hercules-ci/flake-compat.nix +++ b/hercules-ci/flake-compat.nix @@ -1,6 +1,11 @@ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - inherit (lock.nodes.flake-compat.locked) owner repo rev narHash; + inherit (lock.nodes.flake-compat.locked) + owner + repo + rev + narHash + ; flake-compat = builtins.fetchTarball { url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; sha256 = narHash; diff --git a/hercules-ci/flake.nix b/hercules-ci/flake.nix index 09fc576..5ff3eee 100644 --- a/hercules-ci/flake.nix +++ b/hercules-ci/flake.nix @@ -7,10 +7,16 @@ }; }; - outputs = { self, flake-compat, flake-compat-ci }: { - ciNix = flake-compat-ci.lib.recurseIntoFlakeWith { - flake = self; - systems = [ "x86_64-linux" ]; + outputs = + { + self, + flake-compat, + flake-compat-ci, + }: + { + ciNix = flake-compat-ci.lib.recurseIntoFlakeWith { + flake = self; + systems = [ "x86_64-linux" ]; + }; }; - }; } diff --git a/latexmk/default.nix b/latexmk/default.nix index 3bdff35..dddf40e 100644 --- a/latexmk/default.nix +++ b/latexmk/default.nix @@ -1,4 +1,7 @@ -{ pkgs ? import { }, ... }: +{ + pkgs ? import { }, + ... +}: pkgs.stdenv.mkDerivation { name = "pdf"; diff --git a/latexmk/flake.nix b/latexmk/flake.nix index 8597088..ffd92db 100644 --- a/latexmk/flake.nix +++ b/latexmk/flake.nix @@ -5,12 +5,19 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: let pkgs = nixpkgs.legacyPackages.${system}; in { packages.default = pkgs.callPackage ./default.nix { }; - }); + } + ); } diff --git a/pandoc-xelatex/flake.nix b/pandoc-xelatex/flake.nix index 68057fa..fec81e4 100644 --- a/pandoc-xelatex/flake.nix +++ b/pandoc-xelatex/flake.nix @@ -1,31 +1,36 @@ { description = "A report built with Pandoc, XeLaTex and a custom font"; - outputs = { self, nixpkgs }: { + outputs = + { self, nixpkgs }: + { - packages.x86_64-linux.report = ( + packages.x86_64-linux.report = ( let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - fonts = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; }; + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + fonts = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; }; in - pkgs.stdenv.mkDerivation { - name = "XelatexReport"; - src = ./.; - buildInputs = with pkgs; [ - pandoc - haskellPackages.pandoc-crossref - texlive.combined.scheme-small - ]; - phases = ["unpackPhase" "buildPhase"]; - buildPhase = '' - export FONTCONFIG_FILE=${fonts} - mkdir -p $out - pandoc README.md --filter pandoc-crossref --citeproc --pdf-engine=xelatex -o $out/README.pdf - ''; - } - ); + pkgs.stdenv.mkDerivation { + name = "XelatexReport"; + src = ./.; + buildInputs = with pkgs; [ + pandoc + haskellPackages.pandoc-crossref + texlive.combined.scheme-small + ]; + phases = [ + "unpackPhase" + "buildPhase" + ]; + buildPhase = '' + export FONTCONFIG_FILE=${fonts} + mkdir -p $out + pandoc README.md --filter pandoc-crossref --citeproc --pdf-engine=xelatex -o $out/README.pdf + ''; + } + ); - defaultPackage.x86_64-linux = self.packages.x86_64-linux.report; - }; + defaultPackage.x86_64-linux = self.packages.x86_64-linux.report; + }; } diff --git a/python/flake.nix b/python/flake.nix index e8ecbab..47e71d7 100644 --- a/python/flake.nix +++ b/python/flake.nix @@ -2,28 +2,46 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.poetry2nix.url = "github:nix-community/poetry2nix"; - outputs = { self, nixpkgs, poetry2nix }: + outputs = + { + self, + nixpkgs, + poetry2nix, + }: let - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); in { - packages = forAllSystems (system: let - inherit (poetry2nix.lib.mkPoetry2Nix { pkgs = pkgs.${system}; }) mkPoetryApplication; - in { - default = mkPoetryApplication { projectDir = self; }; - }); + packages = forAllSystems ( + system: + let + inherit (poetry2nix.lib.mkPoetry2Nix { pkgs = pkgs.${system}; }) mkPoetryApplication; + in + { + default = mkPoetryApplication { projectDir = self; }; + } + ); - devShells = forAllSystems (system: let - inherit (poetry2nix.lib.mkPoetry2Nix { pkgs = pkgs.${system}; }) mkPoetryEnv; - in { - default = pkgs.${system}.mkShellNoCC { - packages = with pkgs.${system}; [ - (mkPoetryEnv { projectDir = self; }) - poetry - ]; - }; - }); + devShells = forAllSystems ( + system: + let + inherit (poetry2nix.lib.mkPoetry2Nix { pkgs = pkgs.${system}; }) mkPoetryEnv; + in + { + default = pkgs.${system}.mkShellNoCC { + packages = with pkgs.${system}; [ + (mkPoetryEnv { projectDir = self; }) + poetry + ]; + }; + } + ); }; } diff --git a/ruby/default.nix b/ruby/default.nix index 39bacff..2541ddb 100644 --- a/ruby/default.nix +++ b/ruby/default.nix @@ -1,7 +1,9 @@ -(import ( - fetchTarball { +(import + (fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).defaultNix + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; + }) + { + src = ./.; + } +).defaultNix diff --git a/ruby/flake.nix b/ruby/flake.nix index 4aca5e5..faaad8b 100644 --- a/ruby/flake.nix +++ b/ruby/flake.nix @@ -1,14 +1,20 @@ { # Based on https://github.com/bobvanderlinden/templates/blob/master/ruby/flake.nix # Useage: see README.md - + inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; flake-utils.url = "github:numtide/flake-utils"; -}; + }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: let pkgs = nixpkgs.legacyPackages.${system}; r10k = pkgs.bundlerEnv { @@ -17,17 +23,20 @@ lockfile = ./Gemfile.lock; gemset = ./gemset.nix; }; - in { + in + { - defaultPackage = r10k; + defaultPackage = r10k; - # used by nix shell and nix develop - devShell = with pkgs; - mkShell { - buildInputs = [ - ruby - bundix - ]; - }; - }); + # used by nix shell and nix develop + devShell = + with pkgs; + mkShell { + buildInputs = [ + ruby + bundix + ]; + }; + } + ); } diff --git a/ruby/gemset.nix b/ruby/gemset.nix index 95a5dc3..d0224d2 100644 --- a/ruby/gemset.nix +++ b/ruby/gemset.nix @@ -1,175 +1,199 @@ { colored2 = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0jlbqa9q4mvrm73aw9mxh23ygzbjiqwisl32d8szfb5fxvbjng5i"; type = "gem"; }; version = "3.1.2"; }; cri = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1h45kw2s4bjwgbfsrncs30av0j4zjync3wmcc6lpdnzbcxs7yms2"; type = "gem"; }; version = "2.15.10"; }; faraday = { - dependencies = ["multipart-post"]; - groups = ["default"]; - platforms = []; + dependencies = [ "multipart-post" ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0bs2lm0wd273kwq8nk1p8pk43n1wrizv4c1bdywkpcm9g2f5sp6p"; type = "gem"; }; version = "0.17.5"; }; faraday_middleware = { - dependencies = ["faraday"]; - groups = ["default"]; - platforms = []; + dependencies = [ "faraday" ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1x7jgvpzl1nm7hqcnc8carq6yj1lijq74jv8pph4sb3bcpfpvcsc"; type = "gem"; }; version = "0.14.0"; }; fast_gettext = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0ci71w9jb979c379c7vzm88nc3k6lf68kbrsgw9nlx5g4hng0s78"; type = "gem"; }; version = "1.1.2"; }; gettext = { - dependencies = ["locale" "text"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; + dependencies = [ + "locale" + "text" + ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; sha256 = "0764vj7gacn0aypm2bf6m46dzjzwzrjlmbyx6qwwwzbmi94r40wr"; type = "gem"; }; version = "3.2.9"; }; gettext-setup = { - dependencies = ["fast_gettext" "gettext" "locale"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; + dependencies = [ + "fast_gettext" + "gettext" + "locale" + ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; sha256 = "1vfnayz20xd8q0sz27816kvgia9z2dpj9fy7z15da239wmmnz7ga"; type = "gem"; }; version = "0.34"; }; jwt = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "036i5fc09275ms49mw43mh4i9pwaap778ra2pmx06ipzyyjl6bfs"; type = "gem"; }; version = "2.2.3"; }; locale = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0997465kxvpxm92fiwc2b16l49mngk7b68g5k35ify0m3q0yxpdn"; type = "gem"; }; version = "2.1.3"; }; log4r = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0ri90q0frfmigkirqv5ihyrj59xm8pq5zcmf156cbdv4r4l2jicv"; type = "gem"; }; version = "1.1.10"; }; minitar = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "126mq86x67d1p63acrfka4zx0cx2r0vc93884jggxnrmmnzbxh13"; type = "gem"; }; version = "0.9"; }; multi_json = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0pb1g1y3dsiahavspyzkdy39j4q377009f6ix0bh1ag4nqw43l0z"; type = "gem"; }; version = "1.15.0"; }; multipart-post = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1zgw9zlwh2a6i1yvhhc4a84ry1hv824d6g2iw2chs3k5aylpmpfj"; type = "gem"; }; version = "2.1.1"; }; puppet_forge = { - dependencies = ["faraday" "faraday_middleware" "gettext-setup" "minitar" "semantic_puppet"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; + dependencies = [ + "faraday" + "faraday_middleware" + "gettext-setup" + "minitar" + "semantic_puppet" + ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; sha256 = "1jp9jczc11vxr6y57lxhxxd59vqa763h4qbsbjh1j0yhfagcv877"; type = "gem"; }; version = "2.3.4"; }; r10k = { - dependencies = ["colored2" "cri" "fast_gettext" "gettext" "gettext-setup" "jwt" "log4r" "minitar" "multi_json" "puppet_forge"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; + dependencies = [ + "colored2" + "cri" + "fast_gettext" + "gettext" + "gettext-setup" + "jwt" + "log4r" + "minitar" + "multi_json" + "puppet_forge" + ]; + groups = [ "default" ]; + platforms = [ ]; + source = { + remotes = [ "https://rubygems.org" ]; sha256 = "03hi93zhi5yz5279v4zgy6jmaddqfhp5kadpjxrxwshzv41pphrk"; type = "gem"; }; version = "3.14.2"; }; semantic_puppet = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0gg1bizlgb8wswxwy3irgppqvd6mlr27qsp0fzpm459wffzq10sx"; type = "gem"; }; version = "1.0.4"; }; text = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1x6kkmsr49y3rnrin91rv8mpc3dhrf3ql08kbccw8yffq61brfrg"; type = "gem"; }; diff --git a/ruby/shell.nix b/ruby/shell.nix index 77db547..c5584b1 100644 --- a/ruby/shell.nix +++ b/ruby/shell.nix @@ -1,7 +1,9 @@ -(import ( - fetchTarball { +(import + (fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).shellNix + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; + }) + { + src = ./.; + } +).shellNix diff --git a/rust-web-server/flake.nix b/rust-web-server/flake.nix index 5cfec29..45e8212 100644 --- a/rust-web-server/flake.nix +++ b/rust-web-server/flake.nix @@ -4,9 +4,14 @@ # Nixpkgs / NixOS version to use. inputs.nixpkgs.url = "nixpkgs/nixos-21.05"; - inputs.import-cargo.url = github:edolstra/import-cargo; - - outputs = { self, nixpkgs, import-cargo }: + inputs.import-cargo.url = "github:edolstra/import-cargo"; + + outputs = + { + self, + nixpkgs, + import-cargo, + }: let # to work with older version of flakes @@ -22,57 +27,75 @@ forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); # Nixpkgs instantiated for supported system types. - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; }); + nixpkgsFor = forAllSystems ( + system: + import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + } + ); - in { + in + { # A Nixpkgs overlay. overlay = final: prev: { - rust-web-server = with final; final.callPackage ({ inShell ? false }: stdenv.mkDerivation rec { - name = "rust-web-server-${version}"; - - # In 'nix develop', we don't need a copy of the source tree - # in the Nix store. - src = if inShell then null else ./.; - - buildInputs = - [ rustc - cargo - ] ++ (if inShell then [ - # In 'nix develop', provide some developer tools. - rustfmt - clippy - ] else [ - (import-cargo.builders.importCargo { - lockFile = ./Cargo.lock; - inherit pkgs; - }).cargoHome - ]); - - target = "--release"; - - buildPhase = "cargo build ${target} --frozen --offline"; - - doCheck = true; - - checkPhase = "cargo test ${target} --frozen --offline"; - - installPhase = - '' - mkdir -p $out - cargo install --frozen --offline --path . --root $out - rm $out/.crates.toml - ''; - }) {}; + rust-web-server = + with final; + final.callPackage ( + { + inShell ? false, + }: + stdenv.mkDerivation rec { + name = "rust-web-server-${version}"; + + # In 'nix develop', we don't need a copy of the source tree + # in the Nix store. + src = if inShell then null else ./.; + + buildInputs = [ + rustc + cargo + ] + ++ ( + if inShell then + [ + # In 'nix develop', provide some developer tools. + rustfmt + clippy + ] + else + [ + (import-cargo.builders.importCargo { + lockFile = ./Cargo.lock; + inherit pkgs; + }).cargoHome + ] + ); + + target = "--release"; + + buildPhase = "cargo build ${target} --frozen --offline"; + + doCheck = true; + + checkPhase = "cargo test ${target} --frozen --offline"; + + installPhase = '' + mkdir -p $out + cargo install --frozen --offline --path . --root $out + rm $out/.crates.toml + ''; + } + ) { }; }; # Provide some binary packages for selected system types. - packages = forAllSystems (system: - { - inherit (nixpkgsFor.${system}) rust-web-server; - }); + packages = forAllSystems (system: { + inherit (nixpkgsFor.${system}) rust-web-server; + }); # The default package for 'nix build'. This makes sense if the # flake provides only one package or there is a clear "main" @@ -80,7 +103,9 @@ defaultPackage = forAllSystems (system: self.packages.${system}.rust-web-server); # Provide a 'nix develop' environment for interactive hacking. - devShell = forAllSystems (system: self.packages.${system}.rust-web-server.override { inShell = true; }); + devShell = forAllSystems ( + system: self.packages.${system}.rust-web-server.override { inShell = true; } + ); # A NixOS module. nixosModules.rust-web-server = @@ -95,34 +120,35 @@ }; # Tests run by 'nix flake check' and by Hydra. - checks = forAllSystems - (system: - with nixpkgsFor.${system}; + checks = forAllSystems ( + system: + with nixpkgsFor.${system}; - { - inherit (self.packages.${system}) rust-web-server; - - # A VM test of the NixOS module. - vmTest = - with import (nixpkgs + "/nixos/lib/testing-python.nix") { - inherit system; - }; - - makeTest { - nodes = { - client = { ... }: { + { + inherit (self.packages.${system}) rust-web-server; + + # A VM test of the NixOS module. + vmTest = + with import (nixpkgs + "/nixos/lib/testing-python.nix") { + inherit system; + }; + + makeTest { + nodes = { + client = + { ... }: + { imports = [ self.nixosModules.rust-web-server ]; }; - }; - - testScript = - '' - start_all() - client.wait_for_unit("multi-user.target") - assert "Hello Nixers" in client.wait_until_succeeds("curl --fail http://localhost:8080/") - ''; }; - } - ); + + testScript = '' + start_all() + client.wait_for_unit("multi-user.target") + assert "Hello Nixers" in client.wait_until_succeeds("curl --fail http://localhost:8080/") + ''; + }; + } + ); }; } diff --git a/rust/default.nix b/rust/default.nix index 39bacff..2541ddb 100644 --- a/rust/default.nix +++ b/rust/default.nix @@ -1,7 +1,9 @@ -(import ( - fetchTarball { +(import + (fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).defaultNix + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; + }) + { + src = ./.; + } +).defaultNix diff --git a/rust/flake.nix b/rust/flake.nix index 680de52..1fcfb4d 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -5,18 +5,33 @@ utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, utils, naersk }: - utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + utils, + naersk, + }: + utils.lib.eachDefaultSystem ( + system: let pkgs = import nixpkgs { inherit system; }; naersk-lib = pkgs.callPackage naersk { }; in { defaultPackage = naersk-lib.buildPackage ./.; - devShell = with pkgs; mkShell { - buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ]; - RUST_SRC_PATH = rustPlatform.rustLibSrc; - }; + devShell = + with pkgs; + mkShell { + buildInputs = [ + cargo + rustc + rustfmt + pre-commit + rustPackages.clippy + ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; } ); } diff --git a/rust/shell.nix b/rust/shell.nix index 77db547..c5584b1 100644 --- a/rust/shell.nix +++ b/rust/shell.nix @@ -1,7 +1,9 @@ -(import ( - fetchTarball { +(import + (fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).shellNix + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; + }) + { + src = ./.; + } +).shellNix diff --git a/simple-container/flake.nix b/simple-container/flake.nix index 7bd60b8..61a6369 100644 --- a/simple-container/flake.nix +++ b/simple-container/flake.nix @@ -1,30 +1,35 @@ { inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.03"; - outputs = { self, nixpkgs }: { + outputs = + { self, nixpkgs }: + { - nixosConfigurations.container = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = - [ ({ pkgs, ... }: { - boot.isContainer = true; + nixosConfigurations.container = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ( + { pkgs, ... }: + { + boot.isContainer = true; - # Let 'nixos-version --json' know about the Git revision - # of this flake. - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + # Let 'nixos-version --json' know about the Git revision + # of this flake. + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - # Network configuration. - networking.useDHCP = false; - networking.firewall.allowedTCPPorts = [ 80 ]; + # Network configuration. + networking.useDHCP = false; + networking.firewall.allowedTCPPorts = [ 80 ]; - # Enable a web server. - services.httpd = { - enable = true; - adminAddr = "morty@example.org"; - }; - }) + # Enable a web server. + services.httpd = { + enable = true; + adminAddr = "morty@example.org"; + }; + } + ) ]; - }; + }; - }; + }; } diff --git a/trivial/flake.nix b/trivial/flake.nix index c7a9a1c..7e6ccbb 100644 --- a/trivial/flake.nix +++ b/trivial/flake.nix @@ -5,11 +5,13 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { self, nixpkgs }: { + outputs = + { self, nixpkgs }: + { - packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; - packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + packages.x86_64-linux.default = self.packages.x86_64-linux.hello; - }; + }; } diff --git a/typescript/pnpm-p5js/flake.nix b/typescript/pnpm-p5js/flake.nix index f57f8a8..21cccbc 100644 --- a/typescript/pnpm-p5js/flake.nix +++ b/typescript/pnpm-p5js/flake.nix @@ -4,13 +4,16 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = inputs: - inputs.flake-utils.lib.eachDefaultSystem (system: + outputs = + inputs: + inputs.flake-utils.lib.eachDefaultSystem ( + system: let pkgs = (import (inputs.nixpkgs) { inherit system; }); - in { + in + { devShell = pkgs.mkShell { - buildInputs=[ + buildInputs = [ pkgs.nodePackages.nodejs pkgs.nodePackages.pnpm pkgs.nodePackages.typescript diff --git a/typescript/pnpm/flake.nix b/typescript/pnpm/flake.nix index 9a13150..2d5e51c 100644 --- a/typescript/pnpm/flake.nix +++ b/typescript/pnpm/flake.nix @@ -4,13 +4,16 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = inputs: - inputs.flake-utils.lib.eachDefaultSystem (system: + outputs = + inputs: + inputs.flake-utils.lib.eachDefaultSystem ( + system: let pkgs = (import (inputs.nixpkgs) { inherit system; }); - in { + in + { devShell = pkgs.mkShell { - buildInputs=[ + buildInputs = [ pkgs.nodePackages.pnpm pkgs.nodePackages.typescript pkgs.nodePackages.typescript-language-server diff --git a/utils-generic/flake.nix b/utils-generic/flake.nix index 66da2a0..f8dc50a 100644 --- a/utils-generic/flake.nix +++ b/utils-generic/flake.nix @@ -2,15 +2,22 @@ inputs = { utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in + outputs = { - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ - ]; - }; - } - ); + self, + nixpkgs, + utils, + }: + utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + ]; + }; + } + ); }