-
Notifications
You must be signed in to change notification settings - Fork 1
Do some clean up of the Nix infrastructure #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f6dbde7
Import fileFilter directly instead of via overlay
isomorpheme aaaddcf
Fix comment referring to a private repo
isomorpheme 98d9cdb
Remove special pre-commit setup
isomorpheme 1795986
Use the final-prev convention for overlays instead of self-super
isomorpheme 08904fd
Move Rust devshell code out of the nixpkgs overlay
isomorpheme 20867fd
Remove unnecessary passing around of sources
isomorpheme 07e2adb
Simplify .envrc
isomorpheme 30ba761
Remove vendored Nix install script
isomorpheme c943a54
Merge #22: Do some clean up of the Nix infrastructure
OpsBotPrime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,16 @@ | ||
| # shellcheck disable=SC2148 # .envrc files need no shell directive | ||
| shopt -s dotglob globstar | ||
|
|
||
| # NOTE: This file is based on https://github.com/channable/repository-template/blob/master/.envrc | ||
| # When making edits that apply to other repositories, please update the file there. | ||
|
|
||
| # Add possibility to run a custom envrc that completely overrides the behavior of this envrc. | ||
| CUSTOM_ENVRC=.customenvrc | ||
| if [ -f "$CUSTOM_ENVRC" ]; then | ||
| echo "Using .customenvrc file" | ||
| source_env $CUSTOM_ENVRC | ||
| else | ||
| # Decrease logging output | ||
| # shellcheck disable=SC2034 # unused variable is still read by direnv. | ||
| DIRENV_LOG_FORMAT= | ||
| # Install nix-direnv, which has an improved implementation of `use nix` that | ||
| # caches the Nix environment. Note that this URL is cached locally, so it | ||
| # doesn't fetch the script every time. | ||
| if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then | ||
| # Decrease logging output | ||
| # shellcheck disable=SC2034 # unused variable is still read by direnv. | ||
| DIRENV_LOG_FORMAT= | ||
| # Install nix-direnv, which has an improved implementation of `use nix` that | ||
| # caches the Nix environment. Note that this URL is cached locally, so it | ||
| # doesn't fetch the script every time. | ||
| if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then | ||
| source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" | ||
| fi | ||
|
|
||
| watch_file nix/sources.json nix/sources.nix nix/overlay.nix nix/python-overlay.nix opsqueue/opsqueue.nix /libs/opsqueue_python/opsqueue_python.nix | ||
| fi | ||
|
|
||
| watch_file ./nix/ ./**/*.nix | ||
|
|
||
| use nix default.nix --argstr environment shell | ||
| fi | ||
| use nix default.nix --argstr environment shell | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,16 @@ | ||
| # Overlay for Nixpkgs which holds rust-jobs related packages. | ||
| # | ||
| # Serves as common overlay for this repository. | ||
| # | ||
| self: super: | ||
| # Overlay for Nixpkgs which holds all opsqueue related packages. | ||
| final: prev: | ||
| let | ||
| sources = import ./sources.nix; | ||
| lib = super.pkgs.lib; | ||
| pythonOverlay = import ./python-overlay.nix { inherit sources; }; | ||
| pythonOverlay = import ./python-overlay.nix; | ||
| in | ||
| { | ||
| # A powerful way of filtering the right files for the src attribute of a derivation. | ||
| fileFilter = | ||
| { | ||
| name, | ||
| # Regex whitelist of files | ||
| srcWhitelist ? [ ".*" ], | ||
| # Blacklist of files and directories anywhere in the repository. Use only | ||
| # with files that can appear in multiple places in the repository. | ||
| srcGlobalBlacklist ? [ ], | ||
| # Global whitelist by suffix, only allow the following file extensions | ||
| srcGlobalWhitelist ? [ ], | ||
| # Global whitelist by regex, only allow the following file extensions | ||
| srcGlobalWhitelistRegex ? [ ], | ||
| src, | ||
| }: | ||
| lib.cleanSourceWith rec { | ||
| inherit name src; | ||
| filter = | ||
| path: type: | ||
| let | ||
| relativePath = lib.removePrefix (toString src + "/") path; | ||
| in | ||
| (builtins.any (r: builtins.match r relativePath != null) srcWhitelist) | ||
| && | ||
| # Whitelist these files | ||
| ( | ||
| (type == "directory") | ||
| || ( | ||
| (builtins.length srcGlobalWhitelist != 0) | ||
| && (builtins.any (suffix: lib.hasSuffix suffix relativePath) srcGlobalWhitelist) | ||
| || ( | ||
| (builtins.length srcGlobalWhitelistRegex != 0) | ||
| && (builtins.any (r: builtins.match r relativePath != null) srcGlobalWhitelistRegex) | ||
| ) | ||
| ) | ||
| ) | ||
| && | ||
| # Ignore the files from srcGlobalBlacklist anywhere | ||
| !(builtins.elem (baseNameOf path) srcGlobalBlacklist) | ||
| && | ||
| # Discard editor files, git repo stuff, and other cruft. This one is taken | ||
| # from Nixpkgs; we don't need to implement it ourselves. | ||
| lib.cleanSourceFilter path type; | ||
| }; | ||
|
|
||
| # Placing the sources in the overlay gives all packages access to the sources, | ||
| # and it makes it possible to override them in new overlays. | ||
| sources = if super ? sources then super.sources // sources else sources; | ||
|
|
||
| opsqueue = self.callPackage ../opsqueue/opsqueue.nix { }; | ||
| opsqueue = final.callPackage ../opsqueue/opsqueue.nix { }; | ||
|
|
||
| # The explicit choice is made not to override `python312`, as this will cause a rebuild of many | ||
| # packages when nixpkgs uses python 3.12 as default python environment. | ||
| # These packages should not be affected, e.g. cachix. This is because of a transitive | ||
| # dependency on the Python packages that we override. | ||
| # In our case cachix > ghc > shpinx > Python libraries. | ||
| pythonChannable = super.python312.override { packageOverrides = pythonOverlay; }; | ||
|
|
||
| # We choose a minimal Rust channel to keep the Nix closure size smaller | ||
| rust-with-lsp = self.rust-bin.stable.latest.minimal.override { | ||
| extensions = [ | ||
| "clippy" | ||
| "rustfmt" | ||
| ]; | ||
| }; | ||
| pythonChannable = prev.python312.override { packageOverrides = pythonOverlay; }; | ||
|
|
||
| pre-commit-env = self.buildEnv { | ||
| name = "pre-commit-env"; | ||
| paths = [ | ||
| super.python3Packages.pre-commit-hooks | ||
| super.nixfmt-rfc-style | ||
| super.ruff | ||
| super.biome | ||
| self.rust-with-lsp | ||
| ]; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| { | ||
| sources ? import ./sources.nix, | ||
| }: | ||
| self: super: { opsqueue_python = self.callPackage ../libs/opsqueue_python/opsqueue_python.nix { }; } | ||
| final: prev: { | ||
| opsqueue_python = final.callPackage ../libs/opsqueue_python/opsqueue_python.nix { }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Utility functions to use in nix code | ||
| { lib }: | ||
| { | ||
| # A powerful way of filtering the right files for the src attribute of a derivation. | ||
| fileFilter = | ||
| { | ||
| name, | ||
| # Regex whitelist of files | ||
| srcWhitelist ? [ ".*" ], | ||
| # Blacklist of files and directories anywhere in the repository. Use only | ||
| # with files that can appear in multiple places in the repository. | ||
| srcGlobalBlacklist ? [ ], | ||
| # Global whitelist by suffix, only allow the following file extensions | ||
| srcGlobalWhitelist ? [ ], | ||
| # Global whitelist by regex, only allow the following file extensions | ||
| srcGlobalWhitelistRegex ? [ ], | ||
| src, | ||
| }: | ||
| lib.cleanSourceWith rec { | ||
| inherit name src; | ||
| filter = | ||
| path: type: | ||
| let | ||
| relativePath = lib.removePrefix (toString src + "/") path; | ||
| in | ||
| (builtins.any (r: builtins.match r relativePath != null) srcWhitelist) | ||
| && | ||
| # Whitelist these files | ||
| ( | ||
| (type == "directory") | ||
| || ( | ||
| (builtins.length srcGlobalWhitelist != 0) | ||
| && (builtins.any (suffix: lib.hasSuffix suffix relativePath) srcGlobalWhitelist) | ||
| || ( | ||
| (builtins.length srcGlobalWhitelistRegex != 0) | ||
| && (builtins.any (r: builtins.match r relativePath != null) srcGlobalWhitelistRegex) | ||
| ) | ||
| ) | ||
| ) | ||
| && | ||
| # Ignore the files from srcGlobalBlacklist anywhere | ||
| !(builtins.elem (baseNameOf path) srcGlobalBlacklist) | ||
| && | ||
| # Discard editor files, git repo stuff, and other cruft. This one is taken | ||
| # from Nixpkgs; we don't need to implement it ourselves. | ||
| lib.cleanSourceFilter path type; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍