Skip to content

Commit

Permalink
Merge pull request #130 from mookums-forks/nix
Browse files Browse the repository at this point in the history
Support for NixOS
  • Loading branch information
mookums authored Aug 9, 2024
2 parents e65ee71 + 53a766a commit 2d94a69
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ pyramid-incorrect.dat

# macOS
.DS_Store

# Nix
result
78 changes: 78 additions & 0 deletions flake.lock

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

47 changes: 47 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
description = "Open-source Star Tracker";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";

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

outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
let
overlays = [
(final: prev: rec { lost = prev.callPackage ./nix/package.nix { }; })
];
in flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit overlays system; };
in {
packages.default = pkgs.lost;
packages.lost = pkgs.lost;

devShells.default = pkgs.mkShell {
packages = with pkgs; [
gcc
clang-tools
gnumake
bear
gdb
valgrind
man
groff
imagemagick
cpplint
doxygen
graphviz
unixtools.xxd
eigen
cairo
];
};

devShell = self.devShells.${system}.default;
});
}
29 changes: 29 additions & 0 deletions nix/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ stdenv, pkgs, lib }:

stdenv.mkDerivation rec {
pname = "lost";
version = "0.1.0";

src = ./..;

nativeBuildInputs = with pkgs; [ gcc gnumake groff unixtools.xxd eigen ];

buildInputs = with pkgs; [ cairo ];

dontConfigure = true;

buildPhase = ''
make release
'';

installPhase = ''
mkdir -p $out/bin
mv lost $out/bin/
'';

meta = with lib; {
description = "Open-source Star Tracker";
homepage = "https://github.com/uwcubesat/lost";
license = licenses.mit;
};
}
12 changes: 12 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(import
(
let
flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat;
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz";
sha256 = flake-compat.locked.narHash;
}
)
{src = ./.;})
.shellNix

0 comments on commit 2d94a69

Please sign in to comment.