Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,22 @@ jobs:
run: cargo build
- name: Test
run: cargo test

flake:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Check the flake evaluates
run: nix flake check --no-build
- name: Build
run: nix build .#default --print-build-logs
- name: Run
run: |
out=$(nix build .#default --no-link --print-out-paths)
ls "$out/bin" # both `bootit` and `it` must be installed
nix run .#default -- --version
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ it windows # No sudo required!
cargo install bootit
```

### Nix
Run it straight from the flake, no install step:
```bash
nix run github:mincomk/bootit -- scan
```

Or install it into your profile, which gives you both `bootit` and `it`:
```bash
nix profile install github:mincomk/bootit
sudo bootit allow-non-root
it windows
```

On NixOS you can also pull it from the flake as a package:
```nix
{
inputs.bootit.url = "github:mincomk/bootit";
# then, in your configuration:
environment.systemPackages = [ inputs.bootit.packages.${pkgs.system}.default ];
}
```

## Troubleshooting

### `sudo: bootit: command not found` after `cargo install`
Expand Down
95 changes: 5 additions & 90 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 54 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
{
description = "A very cool CLI tool";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
crane.url = "github:ipetkov/crane";
};

outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
description = "bootit: a lightweight next-boot selector";

rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

bootit = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
buildInputs = with pkgs; [
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});

version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
in
{
packages = forAllSystems (pkgs: rec {
bootit = pkgs.rustPlatform.buildRustPackage {
pname = "bootit";
inherit version;
src = ./.;

cargoLock.lockFile = ./Cargo.lock;

# `it` is a second bin in the same crate; buildRustPackage installs
# every bin, so both `bootit` and `it` land in $out/bin.
meta = {
description = "Lightweight next-boot selector";
homepage = "https://github.com/mincomk/bootit";
license = pkgs.lib.licenses.mit;
mainProgram = "bootit";
platforms = pkgs.lib.platforms.linux;
};
};
in
{
packages.default = bootit;

apps.default = flake-utils.lib.mkApp {
drv = bootit;
default = bootit;
});

apps = forAllSystems (pkgs: {
default = {
type = "app";
program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.bootit}/bin/bootit";
meta.description = "Run bootit without installing it";
};
});

devShells.default = pkgs.mkShell {
buildInputs = [ rustToolchain pkgs.cargo-edit pkgs.rust-analyzer ];
checks = forAllSystems (pkgs: {
bootit = self.packages.${pkgs.stdenv.hostPlatform.system}.bootit;
});

devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = [
pkgs.cargo
pkgs.rustc
pkgs.rustfmt
pkgs.clippy
pkgs.rust-analyzer
];
};
});
};
}
Loading