forked from flyingcircusio/fc-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nix Flake for dev and release tooling
The change turns the repo into a Nix flake (flake.nix + flake.lock). Dependencies are now defined as flake inputs. This doesn't influence runtime behaviour of the platform and we still use versions.json/versions.nix for dependencies but versions.json is now generated by the flake with the same content as before. To modularize and provide convenient abstractions for the flake file, especially when dealing with support for multiple systems/architectures we use [flake-parts](https://flake.parts/). [devenv](devenv.sh) is used to define the development shell which replaces shell.nix and provides unified access to various helper scripts. The shell works for Macs (release tooling is usually run from there) and on Linux (typically developer VMs). As the top-level dir became too crowded, many scripts and files from the top-level which are related to dependency management and the release process moved to the `release` subdir. Their location isn't important anymore as they are meant to be called through scripts generated by devenv now. `./update-nixpkgs.py` is now invoked as `update_nixpkgs`, for example. See the comment at the top of `flake.nix` for more info. ./dev-setup still exists as script for our "muscle memory" but is only a facade now, just calling `dev_setup` running in a dev shell. During the the top-level directory cleanup, fc/ceph/__init__.py which serves no purpose was removed, too. This causes isort (for Python), which is part of the pre-commit hook, to sort imports differrently as fc.ceph is now recognized as external dependency. This explains the changes in pkgs/fc/ceph/fc/ceph. PL-131814
- Loading branch information
Showing
26 changed files
with
772 additions
and
273 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
.eggs/ | ||
.envrc | ||
/*.sublime-* | ||
.devenv/ | ||
__pycache__/ | ||
bin/ | ||
channels | ||
|
This file contains 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 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,52 +1,6 @@ | ||
#!/usr/bin/env bash | ||
# Usage: eval `./dev-setup` | ||
set -e | ||
|
||
echo "This will set up the channels dir and show the export command to set the NIX_PATH accordingly." >&2 | ||
echo "You can also use 'nix develop --impure' to open the dev shell and run build_channels_dir from there." >&2 | ||
# ensure PWD is the directory this script resides in (allows calls like ../dev-setup or $HOME/fc-nixos/dev-setup) | ||
cd "$(dirname "$(readlink -f "$0")")" | ||
|
||
base=$PWD | ||
# preserve nixos-config | ||
config=$(nix-instantiate --find-file nixos-config 2>/dev/null) || true | ||
|
||
# bootstrapping with what we find on the system | ||
for candidate in \ | ||
$HOME/.nix-defexpr/channels/nixos \ | ||
$HOME/.nix-defexpr/channels_root/nixos \ | ||
$HOME/.nix-defexpr/channels \ | ||
$HOME/.nix-defexpr/channels_root; do | ||
if [[ -e ${candidate} ]]; then | ||
NIX_PATH="${NIX_PATH}${NIX_PATH:+:}${candidate}" | ||
fi | ||
done | ||
export NIX_PATH | ||
channels=`nix-build -Q --quiet versions.nix -A allUpstreams --no-out-link` | ||
if [[ -z $channels ]]; then | ||
echo "$0: failed to build nixpkgs+overlay" >&2 | ||
exit 1 | ||
fi | ||
mkdir -p channels | ||
find $channels -maxdepth 1 -type l | while read channel; do | ||
target="channels/${channel##*/}" | ||
# don't toucn anything which is not a link into the nix store | ||
if [[ ! -L $target && -d $target ]]; then | ||
echo "$0: warning: $target appears to be a local dev checkout" >&2 | ||
continue | ||
elif [[ -L $target && $(readlink $target) != /nix/store/* ]]; then | ||
echo "$0: warning: $target appears to be a local dev checkout" >&2 | ||
continue | ||
fi | ||
ln -fs $channel channels | ||
done | ||
if ! [[ -e channels/fc ]]; then | ||
ln -s .. channels/fc | ||
fi | ||
|
||
NIX_PATH="$base/channels" | ||
if [[ -n "$config" ]]; then | ||
NIX_PATH="${NIX_PATH}:nixos-config=$config" | ||
else | ||
NIX_PATH="${NIX_PATH}:nixos-config=${base}/nixos" | ||
fi | ||
|
||
echo "export NIX_PATH=$NIX_PATH" | ||
nix develop --impure "$@" --command dev_setup |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.