Skip to content

Commit

Permalink
refactor(nix,ci): fixed flake for default devshell ; ci for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Aug 9, 2024
1 parent 1a6996f commit 4023f34
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-app-.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build the app

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Nix package manager
uses: DeterminateSystems/nix-installer-action@main

- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build
run: nix build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust Build and Test
name: Run tests

on:
push:
Expand All @@ -22,8 +22,5 @@ jobs:
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build
run: nix develop --command cargo build --verbose

- name: Run tests
run: nix develop --command cargo test --verbose
15 changes: 1 addition & 14 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
lib,
rustPlatform,
stdenv,
openssl,
darwin,
pkg-config,
}:
let
p = (lib.importTOML ./Cargo.toml).package;
Expand All @@ -28,18 +26,7 @@ rustPlatform.buildRustPackage {
lockFile = ./Cargo.lock;
};

buildInputs =
[ openssl ]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
Security
CoreFoundation
SystemConfiguration
]
);

nativeBuildInputs = [ pkg-config ];
buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];

meta = {
inherit (p) description homepage;
Expand Down
5 changes: 2 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (pkgs: rec {
default = hxn;
hxn = pkgs.callPackage ./default.nix {};
packages = forAllSystems (pkgs: {
default = pkgs.callPackage ./default.nix { };
});

devShells = forAllSystems (pkgs: {
Expand Down
31 changes: 19 additions & 12 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
rust-analyzer,
callPackage,
}:
let
mainPkg = callPackage ./default.nix { };
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [
rust-analyzer
] ++ (oa.nativeBuildInputs or [ ]);
})
{ pkgs, ... }:
pkgs.mkShell {

buildInputs =
with pkgs;
[ openssl ]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
Security
CoreFoundation
SystemConfiguration
]
);

shellHook = ''
echo "You are inside the development shell!"
'';
}

0 comments on commit 4023f34

Please sign in to comment.