Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use nix
use flake
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Or install it into your `nix` profile (replace `<VERSION>` with the
latest version):

```sh
nix profile install --file https://github.com/vst/clompse/archive/v<VERSION>.tar.gz app
nix profile install --file https://github.com/vst/clompse/archive/v<VERSION>.tar.gz
```

## Configuration
Expand Down Expand Up @@ -180,7 +180,7 @@ hpack &&

## License

Copyright &copy; 2024 Vehbi Sinan Tunalioglu. This work is licensed
Copyright &copy; 2024-2025 Vehbi Sinan Tunalioglu. This work is licensed
under [MIT License].

<!-- REFERENCES -->
Expand Down
135 changes: 0 additions & 135 deletions default.nix

This file was deleted.

61 changes: 61 additions & 0 deletions flake.lock

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

133 changes: 133 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
description = "clompse - Patrol Cloud Resources";

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

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
## Import nixpkgs:
pkgs = import nixpkgs { inherit system; };

## Load readYAML helper:
readYAML = pkgs.callPackage ./nix/read-yaml.nix { };

## Read package information:
package = readYAML ./package.yaml;

## Get our Haskell:
thisHaskell = pkgs.haskellPackages.override {
overrides = self: super: {
${package.name} = self.callCabal2nix package.name ./. { };
};
};

## Prepare dev-test-build script:
dev-test-build = pkgs.writeShellApplication {
name = "cabal-dev-test-build";
text = builtins.readFile ./nix/dev-test-build.sh;
runtimeInputs = [ pkgs.bash pkgs.bc pkgs.moreutils ];
};

## Prepare Nix shell:
thisShell = thisHaskell.shellFor {
## Define packages for the shell:
packages = p: [ p.${package.name} ];

## Enable Hoogle:
withHoogle = false;

## Build inputs for development shell:
buildInputs = [
## Haskell related build inputs:
thisHaskell.apply-refact
thisHaskell.cabal-fmt
thisHaskell.cabal-install
thisHaskell.cabal2nix
thisHaskell.fourmolu
thisHaskell.haskell-language-server
thisHaskell.hlint
thisHaskell.hpack
thisHaskell.weeder

## Our development scripts:
dev-test-build

## Other build inputs for various development requirements:
pkgs.docker-client
pkgs.git
pkgs.nil
pkgs.nixpkgs-fmt
pkgs.nodePackages.prettier
pkgs.upx
];
};

thisPackage = pkgs.haskell.lib.justStaticExecutables (
thisHaskell.${package.name}.overrideAttrs (oldAttrs: {
nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) ++ [
pkgs.git
pkgs.installShellFiles
pkgs.makeWrapper
pkgs.ronn
];

postFixup = (oldAttrs.postFixup or "") + ''
## Create output directories:
mkdir -p $out/{bin}

## Wrap program to add PATHs to dependencies:
wrapProgram $out/bin/${package.name} --prefix PATH : ${pkgs.lib.makeBinPath [
pkgs.bashInteractive ## Added for bash-based CLI option completions
]}

## Install completion scripts:
installShellCompletion --bash --name ${package.name}.bash <($out/bin/${package.name} --bash-completion-script "$out/bin/${package.name}")
installShellCompletion --fish --name ${package.name}.fish <($out/bin/${package.name} --fish-completion-script "$out/bin/${package.name}")
installShellCompletion --zsh --name _${package.name} <($out/bin/${package.name} --zsh-completion-script "$out/bin/${package.name}")
'';
})
);

thisDocker = pkgs.dockerTools.buildImage {
name = "${package.name}";
tag = "v${package.version}";
created = "now";

copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ pkgs.cacert ];
pathsToLink = [ "/etc" ];
};

runAsRoot = ''
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
groupadd -r users
useradd -r -g users patron
'';

config = {
User = "patron";
Entrypoint = [ "${thisPackage}/bin/${package.name}" ];
Cmd = null;
};
};
in
{
## Project packages output:
packages = {
"${package.name}" = thisPackage;
docker = thisDocker;
default = self.packages.${system}.${package.name};
};

## Project development shell output:
devShells = {
default = thisShell;
};
});
}
31 changes: 0 additions & 31 deletions nix/lib/mk-haskell-app.nix

This file was deleted.

Loading
Loading