ak9im/flake.nix

110 lines
3.1 KiB
Nix

{
description = "Identification and modeling of stochastic signals - protocols";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
...
}: let
projname = "ak9im";
# to work with older version of flakes
lastModifiedDate =
self.lastModifiedDate or self.lastModified or "19700101";
# Generate a user-friendly version number.
version = "v0.0.0";
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [
# no overlay imports atm
# (import ./overlay.nix)
];
});
in {
formatter = forAllSystems (
system:
nixpkgsFor.${system}.alejandra
);
packages = forAllSystems (system: let
baseurl = "https://git.dotya.ml/wanderer/ak9im/";
in rec {
p1 = pkgs.${system}.poetry2nix.mkPoetryApplication {
name = "p1";
projectDir = ./p1;
meta = {
description = self.description + ": p1";
homepage = baseurl + "p1";
license = nixpkgs.lib.licenses.gpl3;
maintainers = ["wanderer"];
platforms = nixpkgs.lib.platforms.linux ++ nixpkgs.lib.platforms.darwin;
};
};
default = p1;
});
apps = forAllSystems (system: rec {
p1 = {
type = "app";
program = "${self.packages.${system}.${projname}}/bin/p1";
};
default = p1;
});
devShells = forAllSystems (system: let
upcache = pkgs.writeShellScriptBin "upcache" ''
## refs:
## https://fzakaria.com/2020/08/11/caching-your-nix-shell.html
## https://nixos.wiki/wiki/Caching_nix_shell_build_inputs
nix-store --query --references $(nix-instantiate shell.nix) | \
xargs nix-store --realise | \
xargs nix-store --query --requisites | \
cachix push ${projname}
nix build --json \
| jq -r '.[].outputs | to_entries[].value' \
| cachix push ${projname}
'';
add-license = pkgs.writeShellScriptBin "add-license" ''
go run github.com/google/addlicense@v1.0.0 -v \
-c "wanderer <a_mirre at utb dot cz>" \
-l "GPL-3.0-or-later" -s .
'';
in {
default = pkgs.${system}.mkShellNoCC {
name = "${projname}-" + version;
shellHook = ''
echo " -- in ${projname} dev shell..."
'';
packages = with pkgs.${system}; [
(poetry2nix.mkPoetryEnv {projectDir = ./p1;})
# ux
python3Packages.pynvim
python3Packages.jedi
pre-commit
# deps
python3Packages.numpy
python3Packages.pandas
python3Packages.matplotlib
python3Packages.scipy
poetry
];
};
});
};
}