This guide covers various ways to install and use safe-clean on Nix and NixOS systems.
- Nix package manager installed (for non-NixOS systems)
- Nix flakes enabled (recommended)
To enable flakes, add this to your ~/.config/nix/nix.conf or /etc/nix/nix.conf:
experimental-features = nix-command flakes
The quickest way to try safe-clean:
nix run github:npsg02/safe-cleanThis will download, build, and run the latest version without installing it permanently.
To install safe-clean to your user profile:
nix profile install github:npsg02/safe-cleanAfter installation, you can run it directly:
safe-cleanTo update to the latest version:
nix profile upgrade safe-cleanTo remove:
nix profile remove safe-cleanCreate a temporary shell with safe-clean available:
nix shell github:npsg02/safe-cleanThis is useful for one-off usage or testing.
For systems not using flakes:
git clone https://github.com/npsg02/safe-clean.git
cd safe-clean
nix-env -if .Add safe-clean as a flake input in your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
safe-clean.url = "github:npsg02/safe-clean";
};
outputs = { self, nixpkgs, safe-clean, ... }: {
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
safe-clean.nixosModules.default
{
programs.safe-clean.enable = true;
}
];
};
};
}In your configuration.nix:
{ config, pkgs, ... }:
{
environment.systemPackages = [
(pkgs.callPackage (builtins.fetchGit {
url = "https://github.com/npsg02/safe-clean.git";
ref = "main";
}) {})
];
}Or using fetchFromGitHub:
{ config, pkgs, ... }:
{
environment.systemPackages = [
(pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "npsg02";
repo = "safe-clean";
rev = "main"; # or a specific commit hash
sha256 = ""; # Run once to get the correct hash
}) {})
];
}After modifying your configuration:
sudo nixos-rebuild switchThe flake provides a development shell with all necessary tools:
# Enter the development shell
nix develop github:npsg02/safe-clean
# Or from a local clone
git clone https://github.com/npsg02/safe-clean.git
cd safe-clean
nix developThe development shell includes:
- Rust stable toolchain
- cargo-watch for automatic rebuilds
- rust-analyzer for IDE support
- pkg-config and other build dependencies
git clone https://github.com/npsg02/safe-clean.git
cd safe-clean
nix build
./result/bin/safe-cleanThe built binary will be available in the result symlink.
For automatic environment loading, create a .envrc file in your clone:
use flakeThen run:
direnv allowNow the development environment will be automatically loaded when you enter the directory.
To use a specific version or commit:
# Using a specific tag
nix run github:npsg02/safe-clean/v0.1.0
# Using a specific commit
nix run github:npsg02/safe-clean/abc1234If you get an error about experimental features:
error: experimental Nix feature 'flakes' is disabled
Enable flakes by adding to ~/.config/nix/nix.conf:
experimental-features = nix-command flakes
If the build fails, try updating your nixpkgs:
nix flake updateAfter installation, if the binary is not found, ensure your PATH includes:
~/.nix-profile/bin(for user installations)/run/current-system/sw/bin(for NixOS system installations)
You can use safe-clean as a dependency in your own Nix projects:
{
inputs = {
safe-clean.url = "github:npsg02/safe-clean";
};
outputs = { self, safe-clean, ... }: {
# Your outputs here
packages.x86_64-linux.my-package = pkgs.stdenv.mkDerivation {
buildInputs = [ safe-clean.packages.x86_64-linux.default ];
};
};
}To add safe-clean to your nixpkgs overlay:
{ config, pkgs, ... }:
{
nixpkgs.overlays = [
(final: prev: {
safe-clean = prev.callPackage (builtins.fetchGit {
url = "https://github.com/npsg02/safe-clean.git";
ref = "main";
}) {};
})
];
environment.systemPackages = [ pkgs.safe-clean ];
}For issues specific to Nix packaging:
- Open an issue at https://github.com/npsg02/safe-clean/issues
- Check the Nix documentation at https://nixos.org/manual/nix/stable/
For general safe-clean usage:
- See the main README: https://github.com/npsg02/safe-clean
- Visit the documentation: https://npsg02.github.io/safe-clean/