Skip to content

Commit

Permalink
Update to NixOS 23.11, and try to fix install issue
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML committed Nov 30, 2023
1 parent 4298c92 commit fbbffc7
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 155 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- run: nix build -L
- run: nix build github:$GITHUB_REPOSITORY/$GITHUB_SHA -L

- name: NixOS check
run: |
sudo mkdir -pv result-nixos
sudo mount -t tmpfs none ./result-nixos
sudo nixos-install \
--flake github:$GITHUB_REPOSITORY/$GITHUB_SHA#check \
--root $PWD/result-nixos \
--no-root-passwd \
--no-bootloader
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nh"
version = "3.4.10"
version = "3.4.11"
edition = "2021"
license = "EUPL-1.2"

Expand Down
40 changes: 0 additions & 40 deletions default.nix

This file was deleted.

30 changes: 30 additions & 0 deletions devshell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
mkShell,
rust-analyzer,
rustfmt,
clippy,
nvd,
nix-output-monitor,
cargo,
rustc,
}:
mkShell {
strictDeps = true;

nativeBuildInputs = [
cargo
rustc

rust-analyzer
rustfmt
clippy
nvd
nix-output-monitor
];

buildInputs = [];

env = {
NH_NOM = "1";
};
}
61 changes: 4 additions & 57 deletions flake.lock

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

90 changes: 35 additions & 55 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,66 +1,46 @@
{
inputs = {
# Not compatible with nixos-23.05
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
nix-filter.url = "github:numtide/nix-filter";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
};

outputs = inputs: let
src = inputs.nix-filter.lib {
root = inputs.self.outPath;
include = [
(inputs.nix-filter.lib.inDirectory "src")
"Cargo.toml"
"Cargo.lock"
"build.rs"
];
};
in
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
];

systems = [
"aarch64-linux"
outputs = {
self,
nixpkgs,
}: let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
];
"aarch64-linux"
# experimental
"x86_64-darwin"
"aarch64-darwin"
] (system: function nixpkgs.legacyPackages.${system});
in {
overlays.default = final: prev: {
nh = final.callPackage ./package.nix {};
};

flake.nixosModules.default = import ./module.nix inputs.self;
packages = forAllSystems (pkgs: rec {
nh = pkgs.callPackage ./package.nix {};
default = nh;
});

perSystem = {
system,
pkgs,
config,
...
}: {
packages = {
default = pkgs.callPackage ./default.nix {inherit src;};
debug = pkgs.callPackage ./default.nix {
inherit src;
buildType = "debug";
};
};
devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./devshell.nix {};
});

overlayAttrs.nh = config.packages.default;
nixosModules.default = import ./module.nix self;

devShells.default = with pkgs;
mkShell {
# Shell with CC
name = "nh-dev";
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
NH_NOM = "1";
packages = [
cargo
rustc
rustfmt
clippy
rust-analyzer-unwrapped
nvd
nix-output-monitor
];
};
nixosConfigurations.check = let
system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
modules = [
nixpkgs.nixosModules.readOnlyPkgs
{nixpkgs.pkgs = nixpkgs.legacyPackages.${system};}
self.nixosModules.default
{boot.isContainer = true;}
];
};
};
};
}
55 changes: 55 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
rustPlatform,
installShellFiles,
makeWrapper,
lib,
nvd,
use-nom ? true,
nix-output-monitor,
buildType ? "release",
}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
propagatedBuildInputs = [nvd] ++ lib.optionals use-nom [nix-output-monitor];
in
rustPlatform.buildRustPackage {
inherit propagatedBuildInputs buildType;
pname = cargoToml.package.name;
inherit (cargoToml.package) version;
cargoLock.lockFile = ./Cargo.lock;

src = lib.fileset.toSource {
root = ./.;
fileset =
lib.fileset.intersection
(lib.fileset.fromSource (lib.sources.cleanSource ./.))
(lib.fileset.unions [
./src
./Cargo.toml
./Cargo.lock
]);
};

nativeBuildInputs = [
installShellFiles
makeWrapper
];

preFixup = ''
mkdir completions
$out/bin/nh completions --shell bash > completions/nh.bash
$out/bin/nh completions --shell zsh > completions/nh.zsh
$out/bin/nh completions --shell fish > completions/nh.fish
installShellCompletion completions/*
'';

postFixup = ''
wrapProgram $out/bin/nh \
--prefix PATH : ${lib.makeBinPath propagatedBuildInputs} \
${lib.optionalString use-nom "--set-default NH_NOM 1"}
'';

meta.mainProgram = "nh";

strictDeps = true;
}

0 comments on commit fbbffc7

Please sign in to comment.