Skip to content

Instantly share code, notes, and snippets.

@lucperkins
Last active May 31, 2024 10:54
Show Gist options
  • Save lucperkins/437600b6aaaf0e1e8f91fb22fe421234 to your computer and use it in GitHub Desktop.
Save lucperkins/437600b6aaaf0e1e8f91fb22fe421234 to your computer and use it in GitHub Desktop.
{
description = "runme application";
inputs = {
nixpkgs.url = "nixpkgs"; # Resolves to github:NixOS/nixpkgs
# Helpers for system-specific outputs
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
# Create system-specific outputs for the standard Nix systems
# https://github.com/numtide/flake-utils/blob/master/default.nix#L3-L9
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
# A simple executable package
packages.default = pkgs.writeScriptBin "runme" ''
echo "I am currently being run!"
'';
# An app that uses the `runme` package
apps.default = {
type = "app";
program = "${self.packages.${system}.runme}/bin/runme";
};
});
}
@olafklingt
Copy link

packages.default needs to be packages.runme or otherway around

@samrose
Copy link

samrose commented May 31, 2024

@lucperkins I was not able to get the above to run as-is but I did make these adjustments and it works

{
  description = "runme application";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs"; # Resolves to github:NixOS/nixpkgs
    # Helpers for system-specific outputs
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    # Create system-specific outputs for the standard Nix systems
    # https://github.com/numtide/flake-utils/blob/master/default.nix#L3-L9
    flake-utils.lib.eachDefaultSystem (system:
      let
      	pkgs = import nixpkgs { inherit system; };
      in
      {
        # A simple executable package
        packages.runme = pkgs.writeScriptBin "runme" ''
          #!/usr/bin/env bash	
          echo "I am currently being run!"
        '';

        # An app that uses the `runme` package
        apps.runme = {
          type = "app";
          program = "${self.packages.${system}.runme}/bin/runme";
        };
      });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment