Skip to content
Open
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ bin
releases
extra/man/chrome-shell.1.gz
extra/man/chrome-shell.1.html
# symbolic link created by nix
result
26 changes: 26 additions & 0 deletions flake.lock

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

64 changes: 64 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
description = "A native messaging host for executing shell commands.";

# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";

outputs = { self, nixpkgs }:
let
# Generate a user-friendly version number.
version = "nightly-4";

# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });

in
{

# enable nix fmt
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;

# Provide some binary packages for selected system types.
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
chrome-shell = pkgs.crystal.buildCrystalPackage {
pname = "chrome-shell";
inherit version;
src = ./.;
format = "shards";

# nix cannot run git commands to generate the version string,
# patch the sources to set the version string
patchPhase = ''
sed -i "s/{{.*}}/\"${version}\"/" src/main.cr
'';
};
});

# Add dependencies that are only needed for development
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
buildInputs = (with pkgs; [ nixd ])
++ (with self.packages.${system}.chrome-shell; nativeBuildInputs ++ buildInputs);
};
});

# The default package for 'nix build'. This makes sense if the
# flake provides only one package or there is a clear "main"
# package.
defaultPackage = forAllSystems (system: self.packages.${system}.chrome-shell);
};
}