Skip to content

Scripts to automatically update a few Nix-related things, like the version of nix-direnv in .envrc files and the NixOS release in of the nixpkgs flake input

License

Notifications You must be signed in to change notification settings

jwillikers/nix-update-scripts

Repository files navigation

Nix Update Scripts

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.

Usage

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.

  1. Add nix-update-scripts to flake.nix and include the desired apps in the flake’s apps output. The following example demonstrates how to do this for the update-nix-direnv and update-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;
            };
          }
        );
    }
  2. 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.

Develop

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.

  1. Install an implementation of Nix, such as Lix used here.

    curl -sSf -L https://install.lix.systems/lix | sh -s -- install
  2. Clone this project’s repository.

    git clone https://github.com/jwillikers/nix-update-scripts.git
  3. Change into the project directory.

    cd nix-update-scripts
  4. Install direnv for your system according to the direnv installation instructions.

    sudo rpm-ostree install direnv
    sudo systemctl reboot
  5. Integrate direnv with your shell by following the instructions on the direnv Setup page.

  6. Permit the direnv configuration for the repository.

    direnv allow
  7. Use nix run to run the appropriate target.

    nix run .#update-nix-direnv

Contributing

Contributions in the form of issues, feedback, and even pull requests are welcome. Make sure to adhere to the project’s Code of Conduct.

Code of Conduct

Refer to the project’s Code of Conduct for details.

License

This repository is licensed under the MIT license.

© 2024 Jordan Williams

Authors

About

Scripts to automatically update a few Nix-related things, like the version of nix-direnv in .envrc files and the NixOS release in of the nixpkgs flake input

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •