feat: add a devshell based on vanilla Nix
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
e9b6e99328
commit
cccaf78059
79
default.nix
79
default.nix
|
@ -1,6 +1,73 @@
|
|||
(import
|
||||
(fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/0f9255e01c2351cc7d116c072cb317785dd33b33.tar.gz";
|
||||
sha256 = "0m9grvfsbwmvgwaxvdzv6cmyvjnlww004gfxjvcl806ndqaxzy4j";
|
||||
})
|
||||
{ src = ./.; }).defaultNix.packages.${builtins.currentSystem}
|
||||
{ sources ? import ./npins, pkgs ? import sources.nixpkgs {} }:
|
||||
{
|
||||
packages = {
|
||||
ofborg = pkgs.rustPlatform.buildRustPackage {
|
||||
name = "ofborg";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
rustPackages.clippy
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
darwin.apple_sdk.frameworks.CoreFoundation
|
||||
]);
|
||||
|
||||
preBuild = ''
|
||||
cargo clippy
|
||||
'';
|
||||
|
||||
doCheck = false; # Tests require access to a /nix/ and a nix daemon
|
||||
checkInputs = with pkgs; [
|
||||
lix
|
||||
];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
shell = pkgs.mkShell {
|
||||
name = "ofborg-devenv";
|
||||
packages = with pkgs; [
|
||||
lix
|
||||
nix-prefetch-git
|
||||
rustc
|
||||
cargo
|
||||
clippy
|
||||
rustfmt
|
||||
pkg-config
|
||||
];
|
||||
|
||||
postHook = ''
|
||||
checkPhase() (
|
||||
cd "${builtins.toString ./.}/ofborg"
|
||||
set -x
|
||||
cargo fmt
|
||||
git diff --exit-code
|
||||
cargofmtexit=$?
|
||||
|
||||
cargo clippy
|
||||
cargoclippyexit=$?
|
||||
|
||||
cargo build && cargo test
|
||||
cargotestexit=$?
|
||||
|
||||
sum=$((cargofmtexit + cargoclippyexit + cargotestexit))
|
||||
exit $sum
|
||||
)
|
||||
'';
|
||||
|
||||
RUSTFLAGS = "-D warnings";
|
||||
RUST_BACKTRACE = "1";
|
||||
RUST_LOG = "ofborg=debug";
|
||||
NIX_PATH = "nixpkgs=${pkgs.path}";
|
||||
};
|
||||
}
|
||||
|
|
27
flake.lock
27
flake.lock
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1720031269,
|
||||
"narHash": "sha256-rwz8NJZV+387rnWpTYcXaRNvzUSnnF9aHONoJIYmiUQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f4128e00b0ae8ec65918efeba59db998750ead6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
115
flake.nix
115
flake.nix
|
@ -1,115 +0,0 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, ...
|
||||
}@inputs:
|
||||
let
|
||||
supportedSystems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
in
|
||||
{
|
||||
devShell = forAllSystems (system: inputs.self.devShells.${system}.default);
|
||||
devShells = forAllSystems
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
name = "gh-event-forwarder";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nix # so in --pure mode we actually find the "correct" nix
|
||||
bash
|
||||
nix-prefetch-git
|
||||
rustc
|
||||
cargo
|
||||
clippy
|
||||
rustfmt
|
||||
pkg-config
|
||||
git
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
] ++ lib.optionals stdenv.isDarwin [ darwin.Security libiconv ];
|
||||
|
||||
postHook = ''
|
||||
checkPhase() (
|
||||
cd "${builtins.toString ./.}/ofborg"
|
||||
set -x
|
||||
cargo fmt
|
||||
git diff --exit-code
|
||||
cargofmtexit=$?
|
||||
|
||||
cargo clippy
|
||||
cargoclippyexit=$?
|
||||
|
||||
cargo build && cargo test
|
||||
cargotestexit=$?
|
||||
|
||||
sum=$((cargofmtexit + cargoclippyexit + cargotestexit))
|
||||
exit $sum
|
||||
)
|
||||
'';
|
||||
|
||||
RUSTFLAGS = "-D warnings";
|
||||
RUST_BACKTRACE = "1";
|
||||
RUST_LOG = "ofborg=debug";
|
||||
NIX_PATH = "nixpkgs=${pkgs.path}";
|
||||
};
|
||||
});
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
pkg = pkgs.rustPlatform.buildRustPackage {
|
||||
name = "ofborg";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
pkgs.rustPackages.clippy
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
darwin.apple_sdk.frameworks.CoreFoundation
|
||||
]);
|
||||
|
||||
preBuild = ''
|
||||
cargo clippy
|
||||
'';
|
||||
|
||||
doCheck = false; # Tests require access to a /nix/ and a nix daemon
|
||||
checkInputs = with pkgs; [
|
||||
nix
|
||||
];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
default = pkg;
|
||||
ofborg = pkg;
|
||||
});
|
||||
|
||||
hydraJobs = {
|
||||
buildRs = forAllSystems (system: self.packages.${system}.ofborg);
|
||||
};
|
||||
};
|
||||
}
|
80
npins/default.nix
Normal file
80
npins/default.nix
Normal file
|
@ -0,0 +1,80 @@
|
|||
# Generated by npins. Do not modify; will be overwritten regularly
|
||||
let
|
||||
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||
version = data.version;
|
||||
|
||||
mkSource =
|
||||
spec:
|
||||
assert spec ? type;
|
||||
let
|
||||
path =
|
||||
if spec.type == "Git" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "GitRelease" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "PyPi" then
|
||||
mkPyPiSource spec
|
||||
else if spec.type == "Channel" then
|
||||
mkChannelSource spec
|
||||
else
|
||||
builtins.throw "Unknown source type ${spec.type}";
|
||||
in
|
||||
spec // { outPath = path; };
|
||||
|
||||
mkGitSource =
|
||||
{
|
||||
repository,
|
||||
revision,
|
||||
url ? null,
|
||||
hash,
|
||||
branch ? null,
|
||||
...
|
||||
}:
|
||||
assert repository ? type;
|
||||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||||
# In the latter case, there we will always be an url to the tarball
|
||||
if url != null then
|
||||
(builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
})
|
||||
else
|
||||
assert repository.type == "Git";
|
||||
let
|
||||
urlToName =
|
||||
url: rev:
|
||||
let
|
||||
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
|
||||
|
||||
short = builtins.substring 0 7 rev;
|
||||
|
||||
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
|
||||
in
|
||||
"${if matched == null then "source" else builtins.head matched}${appendShort}";
|
||||
name = urlToName repository.url revision;
|
||||
in
|
||||
builtins.fetchGit {
|
||||
url = repository.url;
|
||||
rev = revision;
|
||||
inherit name;
|
||||
narHash = hash;
|
||||
};
|
||||
|
||||
mkPyPiSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchurl {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
|
||||
mkChannelSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
in
|
||||
if version == 4 then
|
||||
builtins.mapAttrs (_: mkSource) data.pins
|
||||
else
|
||||
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
11
npins/sources.json
Normal file
11
npins/sources.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"pins": {
|
||||
"nixpkgs": {
|
||||
"type": "Channel",
|
||||
"name": "nixpkgs-unstable",
|
||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre698484.30c9efeef01e/nixexprs.tar.xz",
|
||||
"hash": "079c53r3wryasv3ghyi2da9ipxh1bfh2pl63yj447bilh5ghjhhz"
|
||||
}
|
||||
},
|
||||
"version": 4
|
||||
}
|
Loading…
Reference in a new issue