Skip to content

nix local setup

github-actions edited this page Apr 6, 2025 · 3 revisions

Nix is a package manager that uses a purely functional approach to dependency management. Packages in Nix are built and run in isolated, reproducible environments. This tutorial walks you through setting up a development environment for Onefetch using Nix.

This guide assumes you already have Nix installed on your system.

Setup

To begin, create a flake.nix file with the following content:

{
  description = "onefetch";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  }: let
  forAllSystems = fn: nixpkgs.lib.genAttrs [
    "aarch64-darwin"
    "aarch64-linux"
    "i686-linux"
    "x86_64-linux"
    "x86_64-darwin"
  ] (system: fn nixpkgs.legacyPackages.${system});
  in {
    devShells = forAllSystems (pkgs: {
      default = pkgs.mkShell {
        name = "onefetch";
        packages = with pkgs; [
          cargo
          rustc
          clippy
          rustfmt
          rust-analyzer
          cmake
        ];
        RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
      };
    });
  };
}

then enter the development shell:

nix develop
Clone this wiki locally