Skip to content

Commit

Permalink
Merge pull request #76 from nikstur/independence-from-flake-compat
Browse files Browse the repository at this point in the history
Independence from flake compat
  • Loading branch information
nikstur committed Feb 29, 2024
2 parents 806823f + 44ca45f commit 06d01a5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 59 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ niv add nikstur/bombon
let
sources = import ./nix/sources.nix { };
pkgs = import sources.nixpkgs { };
bombon = import sources.bombon;
system = "x86_64-linux";
bombon = import sources.bombon { inherit pkgs; };
in
bombon.lib.${system}.buildBom pkgs.hello { }
bombon.buildBom pkgs.hello { }
```

## Options
Expand Down
21 changes: 11 additions & 10 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
{ pkgs }: rec {

transformer = pkgs.callPackage ./nix/packages/transformer.nix { };

buildBom = pkgs.callPackage ./nix/build-bom.nix {
inherit transformer;
buildtimeDependencies = pkgs.callPackage ./nix/buildtime-dependencies.nix { };
runtimeDependencies = pkgs.callPackage ./nix/runtime-dependencies.nix { };
};

}
5 changes: 2 additions & 3 deletions examples/niv/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
let
sources = import ./nix/sources.nix { };
pkgs = import sources.nixpkgs { };
bombon = import sources.bombon;
system = "x86_64-linux";
bombon = import sources.bombon { inherit pkgs; };
in
bombon.lib.${system}.buildBom pkgs.hello { }
bombon.buildBom pkgs.hello { }
11 changes: 3 additions & 8 deletions flake.lock

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

28 changes: 2 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,16 @@
inputs.systems.follows = "systems";
};

flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};

flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};

gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
gitignore.follows = "gitignore";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};

Expand Down Expand Up @@ -70,18 +58,8 @@

perSystem = { config, system, pkgs, lib, ... }:
let
# Include the Git commit hash as the version of bombon in generated Boms
GIT_COMMIT = lib.optionalString (self ? rev) self.rev;

transformer = pkgs.callPackage ./nix/packages/transformer.nix {
inherit GIT_COMMIT;
};

buildBom = pkgs.callPackage ./nix/build-bom.nix {
inherit transformer;
buildtimeDependencies = pkgs.callPackage ./nix/buildtime-dependencies.nix { };
runtimeDependencies = pkgs.callPackage ./nix/runtime-dependencies.nix { };
};
bombon = import ./. { inherit pkgs; };
inherit (bombon) transformer buildBom;
in
{
_module.args.pkgs = import inputs.nixpkgs {
Expand Down Expand Up @@ -138,8 +116,6 @@
inputsFrom = [ transformer ];

RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

inherit GIT_COMMIT;
};

};
Expand Down
9 changes: 1 addition & 8 deletions nix/packages/transformer.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
{ lib
, rustPlatform
, gitignoreSource

, GIT_COMMIT
}:

rustPlatform.buildRustPackage {
pname = "bombon-transformer";
version = (builtins.fromTOML (builtins.readFile ../../rust/transformer/Cargo.toml)).package.version;

src = gitignoreSource ../../rust/transformer;
src = lib.sourceFilesBySuffices ../../rust/transformer [ ".rs" ".toml" ".lock" ];

cargoLock = {
lockFile = ../../rust/transformer/Cargo.lock;
};

env = {
inherit GIT_COMMIT;
};

meta = with lib; {
homepage = "https://github.com/nikstur/bombon";
license = licenses.mit;
Expand Down
2 changes: 1 addition & 1 deletion rust/transformer/src/cyclonedx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use cyclonedx_bom::models::tool::{Tool, Tools};

use crate::buildtime_input::{self, Derivation, Meta};

const VERSION: &str = env!("GIT_COMMIT");
const VERSION: &str = env!("CARGO_PKG_VERSION");

pub struct CycloneDXBom(Bom);

Expand Down

0 comments on commit 06d01a5

Please sign in to comment.