home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit f66d72b1128c640f75bb80b7b56c6f350b8ed4f1
parent a4723e3fee1fc4c01ce71cee300a9ef6e4b4d281
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Tue, 23 Aug 2022 13:47:52 +0200

flake: migrate "all" shells to flakes…

… even the src/{tektoncd,osp} ones

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
M.envrc | 5+++--
Mflake.nix | 60++++++++++++++++++++++++++++++++++++++++++++++--------------
Mshell.nix | 37+++++--------------------------------
Ashells/default.nix | 2++
Ashells/nixos-config.nix | 25+++++++++++++++++++++++++
Ashells/osp.nix | 31+++++++++++++++++++++++++++++++
Ashells/tekton.nix | 24++++++++++++++++++++++++
Musers/vincent/dev/src/osp.shell.nix | 40++++++----------------------------------
Musers/vincent/dev/src/tektoncd.shell.nix | 33++++++---------------------------
9 files changed, 148 insertions(+), 109 deletions(-)

diff --git a/.envrc b/.envrc @@ -1,2 +1,3 @@ -use flake -test -f .secrets && source .secrets || echo "no secrets" +# use flake +# test -f .secrets && source .secrets || echo "no secrets" +eval "$(lorri direnv)" diff --git a/flake.nix b/flake.nix @@ -64,6 +64,7 @@ , envfs , nixos-wsl , nixos-hardware + , devshell , ... } @ inputs: let @@ -112,6 +113,7 @@ (import ./nix/overlays/sbr.nix) emacs-overlay.overlay nur.overlay + devshell.overlay ]; hostDefaults = { @@ -122,6 +124,7 @@ inherit self; }; modules = with nixosModules; [ + { nix.generateRegistryFromInputs = true; } # Exported modules buildkit # Common modules @@ -234,6 +237,7 @@ outputsBuilder = channels: let + pkgs = channels.nixpkgs; in { overlays.default = import ./nix/overlays; @@ -255,22 +259,50 @@ }; # `nix develop` - devShell = + # devShells = forEachSystem (system: + # let + # pkgs = pkgsBySystem."${system}"; + # in + # { + # cargo = import ./nix/shells/cargo.nix { inherit pkgs; }; + # generic-nightly-rust = import ./nix/shells/generic-nightly-rust.nix { inherit pkgs; }; + # llvm-clang = import ./nix/shells/llvm-clang.nix { inherit pkgs; }; + # rustc = import ./nix/shells/rustc.nix { inherit pkgs; }; + # rustc-perf = import ./nix/shells/rustc-perf.nix { inherit pkgs; }; + # zulip = import ./nix/shells/zulip.nix { inherit pkgs; }; + # } + # ); + devShells = let - inherit (sops-nix.packages."x86_64-linux") sops-import-keys-hook; + ls = builtins.readDir ./shells; + files = builtins.filter (name: ls.${name} == "regular") (builtins.attrNames ls); + shellNames = builtins.map (filename: builtins.head (builtins.split "\\." filename)) files; + nameToValue = name: import (./shells + "/${name}.nix") { inherit pkgs inputs; }; in - with channels.nixpkgs; mkShell { - sopsPGPKeyDirs = [ "./secrets/keys" ]; - nativeBuildInputs = [ - sops-import-keys-hook - ]; - buildInputs = with pkgs; [ - cachix - git - nixpkgs-fmt - sops - ]; - }; + builtins.listToAttrs (builtins.map (name: { inherit name; value = nameToValue name; }) shellNames); + # devShell = + # let + # inherit (sops-nix.packages."x86_64-linux") sops-import-keys-hook; + # in + # with channels.nixpkgs; mkShell { + # sopsPGPKeyDirs = [ "./secrets/keys" ]; + # nativeBuildInputs = [ + # sops-import-keys-hook + # ]; + # buildInputs = with pkgs; [ + # cachix + # git + # nixpkgs-fmt + # sops + # yq-go + # ]; + # shellHook = '' + # test -f .secrets && source .secrets || echo "no secrets" + # export QEMU_OPTS="-m 8096 -cpu host" + # export PATH="${builtins.toString ./.}/bin:$PATH" + # export REPO_ROOT="${builtins.toString ./.}" + # ''; + # }; }; }; } diff --git a/shell.nix b/shell.nix @@ -1,32 +1,5 @@ -let - sources = import ./nix; - pkgs = sources.nixpkgs { }; - nixos-unstable = sources.pkgs-unstable { }; - nixos = sources.pkgs { }; - sops-nix = sources.sops-nix; -in -pkgs.mkShell -{ - name = "nix-config"; - sopsPGPKeyDirs = [ - "./secrets/keys" - ]; - nativeBuildInputs = [ - (pkgs.callPackage sops-nix { }).sops-import-keys-hook - ]; - buildInputs = with pkgs; [ - cachix - morph - niv - nixpkgs-fmt - sops - yq-go - ]; - shellHook = '' - export NIX_PATH="nixpkgs=${pkgs.path}:nixos=${nixos.path}:nixos-unstable=${nixos-unstable.path}" - test -f .secrets && source .secrets || echo "no secrets" - export QEMU_OPTS="-m 8096 -cpu host" - export PATH="${builtins.toString ./.}/bin:$PATH" - export REPO_ROOT="${builtins.toString ./.}" - ''; -} +{ system ? builtins.currentSystem }: + +# Use flake.nix devshell, similar to "nix develop" +(builtins.getFlake (toString ./.)).devShell.${system} + diff --git a/shells/default.nix b/shells/default.nix @@ -0,0 +1,2 @@ +import ./nixos-config.nix + diff --git a/shells/nixos-config.nix b/shells/nixos-config.nix @@ -0,0 +1,25 @@ +{ pkgs, inputs }: +let + inherit (inputs.sops-nix.packages."x86_64-linux") sops-import-keys-hook; +in +pkgs.mkShell +{ + name = "NixOS config"; + sopsPGPKeyDirs = [ "./secrets/keys" ]; + nativeBuildInputs = [ + inputs.sops-nix.packages."x86_64-linux".sops-import-keys-hook + ]; + buildInputs = with pkgs; [ + cachix + git + nixpkgs-fmt + sops + yq-go + ]; + shellHook = '' + test -f .secrets && source .secrets || echo "no secrets" + export QEMU_OPTS="-m 8096 -cpu host" + export PATH="${builtins.toString ./.}/bin:$PATH" + export REPO_ROOT="${builtins.toString ./.}" + ''; +} diff --git a/shells/osp.nix b/shells/osp.nix @@ -0,0 +1,31 @@ +{ pkgs, ... }: +let + go = pkgs.go_1_18; +in +pkgs.mkShell { + name = "osp"; + buildInputs = with pkgs; [ + curl + docker-client + gawk + git-crypt + gnumake + gron + jq + kustomize + my.oc + my.operator-sdk + my.tkn + python39Packages.pyaml + skopeo + yq-go + go + ]; + shellHook = '' + export GOMODULE=on + export GOFLAGS="-mod=vendor" + export GOROOT=${go}/share/go + export GOMAXPROCS=8 + export KUSTOMIZE_BIN=${pkgs.kustomize}/bin/kustomize + ''; +} diff --git a/shells/tekton.nix b/shells/tekton.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +let + go = pkgs.go_1_18; +in +pkgs.mkShell { + name = "tektoncd"; + buildInputs = with pkgs; [ + go + ko + my.oc + my.tkn + google-cloud-sdk + gron + ]; + shellHook = '' + export GOMODULE=on + export GOFLAGS="-mod=vendor" + export GOROOT=${go}/share/go + export GOMAXPROCS=8 + export KUSTOMIZE_BIN=${pkgs.kustomize}/bin/kustomize + export KO_BIN=${pkgs.ko}/bin/ko + export KO_DOCKER_REPO=gcr.io/vde-tekton + ''; +} diff --git a/users/vincent/dev/src/osp.shell.nix b/users/vincent/dev/src/osp.shell.nix @@ -1,34 +1,6 @@ -let - sources = import /etc/nixos/nix; - # pkgs = sources.nixpkgs { }; - pkgs = sources.pkgs-unstable { }; - my = import /etc/nixos/nix/packages { pkgs = pkgs; }; - go = pkgs.go_1_16; -in -pkgs.mkShell { - name = "osp"; - buildInputs = with pkgs; [ - curl - docker-client - gawk - git-crypt - gnumake - gron - jq - kustomize - my.oc - my.operator-sdk - my.tkn - python39Packages.pyaml - skopeo - yq-go - go - ]; - shellHook = '' - export GOMODULE=on - export GOFLAGS="-mod=vendor" - export GOROOT=${go}/share/go - export GOMAXPROCS=8 - export KUSTOMIZE_BIN=${pkgs.kustomize}/bin/kustomize - ''; -} +{ system ? builtins.currentSystem }: + +# Use flake.nix devshell, similar to "nix develop" +(builtins.getFlake (toString /home/vincent/src/home)).devShells.${system}.osp + + diff --git a/users/vincent/dev/src/tektoncd.shell.nix b/users/vincent/dev/src/tektoncd.shell.nix @@ -1,27 +1,6 @@ -let - sources = import /etc/nixos/nix; - # pkgs = sources.nixpkgs { }; - pkgs = sources.pkgs-unstable { }; - my = import /etc/nixos/nix/packages { pkgs = pkgs; }; - go = pkgs.go_1_18; -in -pkgs.mkShell { - name = "tektoncd"; - buildInputs = with pkgs; [ - go - my.ko - my.oc - my.tkn - google-cloud-sdk - gron - ]; - shellHook = '' - export GOMODULE=on - export GOFLAGS="-mod=vendor" - export GOROOT=${go}/share/go - export GOMAXPROCS=8 - export KUSTOMIZE_BIN=${pkgs.kustomize}/bin/kustomize - export KO_BIN=${my.ko}/bin/ko - export KO_DOCKER_REPO=gcr.io/vde-tekton - ''; -} +{ system ? builtins.currentSystem }: + +# Use flake.nix devshell, similar to "nix develop" +(builtins.getFlake (toString ./.)).devShell.${system}.tekton + +