From 7924b83423cff9d94a334d49ecf9fe63722e0d4f Mon Sep 17 00:00:00 2001 From: Jashandeep Sohi <95394050+jashan-lco@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:36:54 -0800 Subject: [PATCH] Convert to flake (#1) --- .envrc | 4 +- .github/workflows/main.yaml | 16 +- .gitignore | 12 +- README.md | 21 +- devenv.lock | 156 ------------ devenv.nix | 38 --- devenv.yaml | 3 - flake.lock | 487 ++++++++++++++++++++++++++++++++++++ flake.nix | 101 ++++++++ kpt.nix | 24 -- kpt/flake.lock | 81 ++++++ kpt/flake.nix | 54 ++++ octopilot.nix | 29 --- octopilot/flake.lock | 81 ++++++ octopilot/flake.nix | 59 +++++ 15 files changed, 894 insertions(+), 272 deletions(-) delete mode 100644 devenv.lock delete mode 100644 devenv.nix delete mode 100644 devenv.yaml create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 kpt.nix create mode 100644 kpt/flake.lock create mode 100644 kpt/flake.nix delete mode 100644 octopilot.nix create mode 100644 octopilot/flake.lock create mode 100644 octopilot/flake.nix diff --git a/.envrc b/.envrc index 6de8a8a..cffc922 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1 @@ -source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" - -use devenv \ No newline at end of file +use flake . --impure diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c4c17d8..2a2f48f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,8 +4,9 @@ concurrency: on: push: - branches: + branches: - main + - flake jobs: update: @@ -15,13 +16,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v23 + + - name: Install nix + uses: cachix/install-nix-action@v24 + with: + extra_nix_config: | + accept-flake-config = true + - uses: cachix/cachix-action@v12 with: name: lco-public extraPullNames: devenv authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - name: Install devenv.sh - run: nix profile install tarball+https://install.devenv.sh/latest + - name: Build - run: devenv ci + run: nix develop --impure diff --git a/.gitignore b/.gitignore index c4300bc..26d999e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1 @@ - -# Devenv -.devenv* -devenv.local.nix - -# direnv -.direnv - -# pre-commit -.pre-commit-config.yaml - +.devenv diff --git a/README.md b/README.md index 08083e5..ef870cf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ A reusable [devenv](https://devenv.sh/) w/ common tools needed for Kubernetes ## Usage +```shell +nix develop --impure +``` + +### Import + To import this devenv into another, add the following to your `devenv.yaml`: ```diff @@ -17,13 +23,16 @@ index c7cb5ce..75410d4 100644 url: github:NixOS/nixpkgs/nixpkgs-unstable + k8s: + url: git+https://github.com/LCOGT/devenv-k8s -+ flake: false ++ flake: true +imports: + - k8s ``` -Next time you do `devenv shell`, it will install all packages listed in [devenv.nix](devenv.nix) -in addition to any project specific ones. +Or if using a flake-parts, add this repo to inputs and follow +https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module + +Next time you do `devenv shell` or `nix develop --impure`, it will install all +packages listed in [devenv.nix](devenv.nix) in addition to any project specific ones. ## Cache @@ -43,3 +52,9 @@ devenv update ``` Or you can declaritively lock it to a specific ref. See https://devenv.sh/reference/yaml-options/. + +For flakes, + +```shell +nix flake update devenv-k8s +``` diff --git a/devenv.lock b/devenv.lock deleted file mode 100644 index f9e77df..0000000 --- a/devenv.lock +++ /dev/null @@ -1,156 +0,0 @@ -{ - "nodes": { - "devenv": { - "locked": { - "dir": "src/modules", - "lastModified": 1701187605, - "narHash": "sha256-NctguPdUeDVLXFsv6vI1RlEiHLsXkeW3pgZe/mwn1BU=", - "owner": "cachix", - "repo": "devenv", - "rev": "a7c4dd8f4eb1f98a6b8f04bf08364954e1e73e4f", - "type": "github" - }, - "original": { - "dir": "src/modules", - "owner": "cachix", - "repo": "devenv", - "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-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "pre-commit-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1701336116, - "narHash": "sha256-kEmpezCR/FpITc6yMbAh4WrOCiT2zg5pSjnKrq51h5Y=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f5c27c6136db4d76c30e533c20517df6864c46ee", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1685801374, - "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1700922917, - "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, - "root": { - "inputs": { - "devenv": "devenv", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/devenv.nix b/devenv.nix deleted file mode 100644 index 7fa9d2a..0000000 --- a/devenv.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, lib, ... }: - -let - kpt = import ./kpt.nix { inherit pkgs lib; }; - octopilot = import ./octopilot.nix { inherit pkgs lib; }; -in -{ - # https://devenv.sh/packages/ - packages = [ - pkgs.git - pkgs.kubectl - pkgs.kind - pkgs.skaffold - pkgs.kubeseal - pkgs.kubernetes-helm - pkgs.kustomize - kpt - octopilot - ]; - - scripts.skaffold-builder-buildx.exec = '' - set -ex - - args="" - - if test "$PUSH_IMAGE" = true; then - args+="--push " - fi - - if test -n "$PLATFORMS"; then - args+="--platform $PLATFORMS " - fi - - docker buildx build "$BUILD_CONTEXT" --tag $IMAGE $args $SKAFFOLD_BUILDX_ARGS - ''; - - # See full reference at https://devenv.sh/reference/options/ -} diff --git a/devenv.yaml b/devenv.yaml deleted file mode 100644 index c7cb5ce..0000000 --- a/devenv.yaml +++ /dev/null @@ -1,3 +0,0 @@ -inputs: - nixpkgs: - url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7f9a742 --- /dev/null +++ b/flake.lock @@ -0,0 +1,487 @@ +{ + "nodes": { + "devenv": { + "inputs": { + "flake-compat": "flake-compat", + "nix": "nix", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1701187605, + "narHash": "sha256-NctguPdUeDVLXFsv6vI1RlEiHLsXkeW3pgZe/mwn1BU=", + "owner": "cachix", + "repo": "devenv", + "rev": "a7c4dd8f4eb1f98a6b8f04bf08364954e1e73e4f", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "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": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "kpt": { + "inputs": { + "flake-parts": "flake-parts_2", + "kpt": "kpt_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-tl+05LnmHU/E2z6CLnQbqMZHv34Qk0GxleGlQkpxqrs=", + "path": "/nix/store/p1rf5sya6cmjzajq37c6bnhb4g2m6ahq-source/kpt", + "type": "path" + }, + "original": { + "path": "/nix/store/p1rf5sya6cmjzajq37c6bnhb4g2m6ahq-source/kpt", + "type": "path" + } + }, + "kpt_2": { + "flake": false, + "locked": { + "lastModified": 1700611672, + "narHash": "sha256-GHEk5nezva+26cpCrgriaGIL2PvSLWgC0UtmFkNHoDc=", + "owner": "kptdev", + "repo": "kpt", + "rev": "aff697dbfc8134b059bcfbdfb792a1048aaa57b5", + "type": "github" + }, + "original": { + "owner": "kptdev", + "ref": "v1.0.0-beta.48", + "repo": "kpt", + "type": "github" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "mk-shell-bin": { + "locked": { + "lastModified": 1677004959, + "narHash": "sha256-/uEkr1UkJrh11vD02aqufCxtbF5YnhRTIKlx5kyvf+I=", + "owner": "rrbutani", + "repo": "nix-mk-shell-bin", + "rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887", + "type": "github" + }, + "original": { + "owner": "rrbutani", + "repo": "nix-mk-shell-bin", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1676545802, + "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", + "owner": "domenkozar", + "repo": "nix", + "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "relaxed-flakes", + "repo": "nix", + "type": "github" + } + }, + "nix2container": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700389764, + "narHash": "sha256-hMsZ741ri9c4ZQpB6mgLY8KErk0yXVAOUjfNkP1nbbw=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "4400b77e14f3095ee3215a9a5e0f9143bc0e8f2d", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678875422, + "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib_3": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1701436327, + "narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "91050ea1e57e50388fa87a3302ba12d188ef723a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "octopilot": { + "inputs": { + "flake-parts": "flake-parts_3", + "nixpkgs": [ + "nixpkgs" + ], + "octopilot": "octopilot_2" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-RweJL6JX9OjVHZEt64hbqb0GcuGt/3LEqwDlvTP/PxM=", + "path": "/nix/store/p1rf5sya6cmjzajq37c6bnhb4g2m6ahq-source/octopilot", + "type": "path" + }, + "original": { + "path": "/nix/store/p1rf5sya6cmjzajq37c6bnhb4g2m6ahq-source/octopilot", + "type": "path" + } + }, + "octopilot_2": { + "flake": false, + "locked": { + "lastModified": 1701682992, + "narHash": "sha256-OEtN4lpeLmA7rw0A4YpVg7FTHZPelOks9gg7AcXB4YU=", + "owner": "dailymotion-oss", + "repo": "octopilot", + "rev": "472d535bae959cf48011ab4d1749f3cbb25c7b84", + "type": "github" + }, + "original": { + "owner": "dailymotion-oss", + "ref": "v1.6.0", + "repo": "octopilot", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1688056373, + "narHash": "sha256-2+SDlNRTKsgo3LBRiMUcoEUb6sDViRNQhzJquZ4koOI=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5843cf069272d92b60c3ed9e55b7a8989c01d4c7", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "flake-parts": "flake-parts", + "kpt": "kpt", + "mk-shell-bin": "mk-shell-bin", + "nix2container": "nix2container", + "nixpkgs": "nixpkgs_2", + "octopilot": "octopilot" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..da05241 --- /dev/null +++ b/flake.nix @@ -0,0 +1,101 @@ +{ + description = "A devenv with common tools needed for K8s, GitOps, etc."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + devenv.url = "github:cachix/devenv"; + nix2container.url = "github:nlewo/nix2container"; + nix2container.inputs.nixpkgs.follows = "nixpkgs"; + mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; + + kpt = { + url = "./kpt"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + octopilot = { + url = "./octopilot"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + }; + + nixConfig = { + extra-trusted-public-keys = '' + "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" + lco-public.cachix.org-1:zSmLK7CkAehZ7QzTLZKt+5Y26Lr0w885GUB4GlT1SCg= + ''; + + extra-substituters = '' + https://devenv.cachix.org + https://lco-public.cachix.org + ''; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.devenv.flakeModule + ]; + + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + + perSystem = { config, self', inputs', pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + packages.kpt = inputs'.kpt.packages.default; + packages.octopilot = inputs'.octopilot.packages.default; + + devenv.shells.default = { + name = "devenv-k8s"; + + imports = [ + # This is just like the imports in devenv.nix. + # See https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module + ]; + + # https://devenv.sh/packages/ + packages = [ + pkgs.git + pkgs.kubectl + pkgs.kind + pkgs.skaffold + pkgs.kubeseal + pkgs.kubernetes-helm + pkgs.kustomize + + inputs'.kpt.packages.default + inputs'.octopilot.packages.default + ]; + + scripts.skaffold-builder-buildx.exec = '' + set -ex + + args="" + + if test "$PUSH_IMAGE" = true; then + args+="--push " + fi + + if test -n "$PLATFORMS"; then + args+="--platform $PLATFORMS " + fi + + docker buildx build "$BUILD_CONTEXT" --tag $IMAGE $args $SKAFFOLD_BUILDX_ARGS + ''; + + # See full reference at https://devenv.sh/reference/options/ + + }; + + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +} diff --git a/kpt.nix b/kpt.nix deleted file mode 100644 index a3c840f..0000000 --- a/kpt.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, lib }: - -pkgs.buildGoModule rec { - pname = "kpt"; - version = "1.0.0-beta.48"; - - src = pkgs.fetchFromGitHub { - owner = "kptdev"; - repo = "${pname}"; - rev = "v${version}"; - hash = "sha256-GHEk5nezva+26cpCrgriaGIL2PvSLWgC0UtmFkNHoDc="; - }; - - vendorHash = "sha256-NQ/JqXokNmr8GlIhqTJb0JFyU2mAEXO+2y5vI79TuX4="; - - subPackages = [ "." ]; - - ldflags = [ "-s" "-w" "-X github.com/GoogleContainerTools/kpt/run.version=${version}" ]; - - meta = with lib; { - description = "Kpt beta"; - }; - -} diff --git a/kpt/flake.lock b/kpt/flake.lock new file mode 100644 index 0000000..63bf19b --- /dev/null +++ b/kpt/flake.lock @@ -0,0 +1,81 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "kpt": { + "flake": false, + "locked": { + "lastModified": 1700611672, + "narHash": "sha256-GHEk5nezva+26cpCrgriaGIL2PvSLWgC0UtmFkNHoDc=", + "owner": "kptdev", + "repo": "kpt", + "rev": "aff697dbfc8134b059bcfbdfb792a1048aaa57b5", + "type": "github" + }, + "original": { + "owner": "kptdev", + "ref": "v1.0.0-beta.48", + "repo": "kpt", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701436327, + "narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "91050ea1e57e50388fa87a3302ba12d188ef723a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "kpt": "kpt", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/kpt/flake.nix b/kpt/flake.nix new file mode 100644 index 0000000..4c05f80 --- /dev/null +++ b/kpt/flake.nix @@ -0,0 +1,54 @@ +{ + description = "Automate Kubernetes Configuration Editing"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + kpt = { + type = "github"; + owner = "kptdev"; + repo = "kpt"; + ref = "v1.0.0-beta.48"; + flake = false; + }; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + + perSystem = { config, self', inputs', pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + packages.default = let + original = import "${inputs.self}/flake.nix"; + in pkgs.buildGoModule rec { + pname = "kpt"; + + version = original.inputs.kpt.ref; + + src = inputs.kpt; + + subPackages = [ "." ]; + + ldflags = [ "-s" "-w" "-X github.com/GoogleContainerTools/kpt/run.version=${version}-g${inputs.kpt.shortRev}" ]; + + vendorHash = "sha256-NQ/JqXokNmr8GlIhqTJb0JFyU2mAEXO+2y5vI79TuX4="; + + meta = { + inherit (original) description; + homepage = "https://github.com/kptdev/kpt"; + }; + + }; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +} diff --git a/octopilot.nix b/octopilot.nix deleted file mode 100644 index f94b032..0000000 --- a/octopilot.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, lib }: - -pkgs.buildGoModule rec { - pname = "octopilot"; - version = "1.5.5"; - - src = pkgs.fetchFromGitHub { - owner = "dailymotion-oss"; - repo = "${pname}"; - rev = "v${version}"; - hash = "sha256-CtCB8iVJlcnb8cxBclqujhIg+AspUWII0EBtVD1ez64="; - }; - - vendorHash = null; - - subPackages = [ "." ]; - - ldflags = [ - "-s" "-w" - "-X main.buildVersion=${version}" - "-X main.buildCommit=v${version}" - ]; - - meta = with lib; { - description = "Automate your Gitops workflow, by automatically creating/merging GitHub Pull Requests "; - homepage = "https://github.com/dailymotion-oss/octopilot"; - }; - -} diff --git a/octopilot/flake.lock b/octopilot/flake.lock new file mode 100644 index 0000000..a5cd973 --- /dev/null +++ b/octopilot/flake.lock @@ -0,0 +1,81 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701436327, + "narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "91050ea1e57e50388fa87a3302ba12d188ef723a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "octopilot": { + "flake": false, + "locked": { + "lastModified": 1701682992, + "narHash": "sha256-OEtN4lpeLmA7rw0A4YpVg7FTHZPelOks9gg7AcXB4YU=", + "owner": "dailymotion-oss", + "repo": "octopilot", + "rev": "472d535bae959cf48011ab4d1749f3cbb25c7b84", + "type": "github" + }, + "original": { + "owner": "dailymotion-oss", + "ref": "v1.6.0", + "repo": "octopilot", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "octopilot": "octopilot" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/octopilot/flake.nix b/octopilot/flake.nix new file mode 100644 index 0000000..c3c14f2 --- /dev/null +++ b/octopilot/flake.nix @@ -0,0 +1,59 @@ +{ + description = "Automate your Gitops workflow, by automatically creating/merging GitHub Pull Requests "; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + octopilot = { + type = "github"; + owner = "dailymotion-oss"; + repo = "octopilot"; + ref = "v1.6.0"; + flake = false; + }; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + + perSystem = { config, self', inputs', pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + packages.default = let + original = import "${inputs.self}/flake.nix"; + in pkgs.buildGoModule rec { + pname = "octopilot"; + + version = original.inputs.octopilot.ref; + + src = inputs.octopilot; + + subPackages = [ "." ]; + + ldflags = [ + "-s" "-w" + "-X main.buildVersion=${version}-g${inputs.octopilot.shortRev}" + "-X main.buildCommit=${inputs.octopilot.rev}" + "-X main.buildDate=${inputs.octopilot.lastModifiedDate}" + ]; + + vendorHash = null; + + meta = { + inherit (original) description; + homepage = "https://github.com/dailymotion-oss/octopilot"; + }; + + }; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +}