Scripts to automatically update a few Nix-related things, like the version of nix-direnv
in .envrc
files and the NixOS release in the nixpkgs
and home-manager
flake inputs.
Use Nix to incorporate these scripts in your project.
Here’s an example of how to incorporate this repository’s flake as part of your project so that nix run
can be used to run the provided scripts.
-
Add
nix-update-scripts
toflake.nix
and include the desired apps in the flake’s apps output. The following example demonstrates how to do this for theupdate-nix-direnv
andupdate-nixos-release
apps.flake.nix{ inputs = { flake-utils.url = "github:numtide/flake-utils"; nix-update-scripts.url = "github:jwillikers/nix-update-scripts"; }; outputs = { self, flake-utils, nix-update-scripts, }: flake-utils.lib.eachDefaultSystem ( system: { apps = { inherit (nix-update-scripts.apps.${system}) update-nix-direnv update-nixos-release; }; } ); }
-
Now it is possible to run the apps using
nix run
like so.nix run .#update-nix-direnv
Examples of how to use these scripts in GitHub Actions can be found in the update-nix-direnv workflow and the update-nixos-release workflow.
The nix develop
command can be used to enter or run commands in an environment with all of the necessary dependencies.
For convenience, direnv can be used to automatically load this environment when entering the project’s directory.
The mkhl.direnv VSCode extension integrates this environment in VSCode for development.
Nix also generates the configuration for pre-commit, which automates formatting and various checks when committing changes.
Follow the instructions here to set up your development environment using Nix.
-
Install an implementation of Nix, such as Lix used here.
curl -sSf -L https://install.lix.systems/lix | sh -s -- install
-
Clone this project’s repository.
git clone https://github.com/jwillikers/nix-update-scripts.git
-
Change into the project directory.
cd nix-update-scripts
-
Install direnv for your system according to the direnv installation instructions.
sudo rpm-ostree install direnv sudo systemctl reboot
-
Integrate direnv with your shell by following the instructions on the direnv Setup page.
-
Permit the direnv configuration for the repository.
direnv allow
-
Use
nix run
to run the appropriate target.nix run .#update-nix-direnv
Contributions in the form of issues, feedback, and even pull requests are welcome. Make sure to adhere to the project’s Code of Conduct.
Refer to the project’s Code of Conduct for details.
This repository is licensed under the MIT license.
© 2024 Jordan Williams