template-nix/flake.nix

71 lines
1.7 KiB
Nix
Raw Normal View History

2024-09-23 17:12:50 +02:00
{
description = "My Project";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
2024-10-22 00:05:50 +02:00
treefmt-nix.url = "github:numtide/treefmt-nix";
2024-09-23 17:12:50 +02:00
};
outputs =
{
self,
flake-utils,
nixpkgs,
2024-10-22 00:05:50 +02:00
treefmt-nix,
2024-09-23 17:12:50 +02:00
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
2024-10-22 00:05:50 +02:00
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
nixfmt.package = pkgs.nixfmt-rfc-style;
shfmt.enable = true;
};
};
2024-09-23 17:12:50 +02:00
in
{
2024-10-22 00:05:50 +02:00
# For `nix fmt`
formatter = treefmtEval.config.build.wrapper;
2024-09-23 17:12:50 +02:00
# Checks/tests for the project
checks = {
# FIXME: Add actual tests
simple-test = pkgs.runCommand "simple-test" { } ''
${self.packages.${system}.default}/bin/my-program
touch $out
'';
};
# Packages
packages = {
my-program = pkgs.writeShellScriptBin "my-program" ''
${pkgs.ddate}/bin/ddate +'Hello, world! Today is the %e of %B%, %Y' |
${pkgs.cowsay}/bin/cowsay
'';
default = self.packages.${system}.my-program;
};
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
just
watchexec
];
shellHook = ''
echo
echo " Welcome to the My Project development environment! "
echo "Run 'just' to see available commands."
echo
'';
};
}
);
}