Application Flakes

I’ve read a lot about flakes and have the concept working on a basic system level. However, I’m struggling to understand how to incorporate flakes that represent an application.

For example, I’ve discovered this git repo (GitHub - devusb/p81-nix: Attempt to repackage perimeter81 .deb to NixOS) containing the repackaging of a .deb installer for an application I wish to use on my NixOS system.

Can someone point me to a resource or explain to me (like I’m a 5 year old), how to leverage this flake with the existing flake I have controlling my overall system? Do I extract the contents of the nix files in the report and import them into my existing flake.nix? Do I clone the report and call it from my existing flake.nix via an import (like the configuration and home manager nix files)?

While I’m interested in this particular application, I’m also trying to use it to establish a broader understanding of how to these sorts of incorporate community efforts (shared as flakes) into my systems.

Thank you

you add the external repository as an input to your flake. the p81-nix repo flake exports a nixos module named perimeter81 that you can add to your configuration. something along the lines:

{ 
  inputs = { p81.url = "..." }; 
  outputs = {p81, ...}: { 
    nixosConfigurations = { 
      myHost = { modules = [p81.perimeter81]; } 
   }; 
  };

Thank you for the pointers. Your suggestions raise two questions.

First, the flake configuration of the repo is somewhat outdated (points to an old version of the application) so I was assuming I’d need to clone it locally to update the out of date references before pulling it into my flake.

Second, simply your suggestion I have the following flake configuration, which I was pretty sure was an inaccurate configuration of the modules line:

'{

description = “Base Flake”;

inputs = {
nixpkgs.url = “nixpkgs/nixos-unstable”;
home-manager.url = “github:nix-community/home-manager/release-25.05”;
home-manager.inputs.nixpkgs.follows = “nixpkgs”;
p81.url = “GitHub - devusb/p81-nix: Attempt to repackage perimeter81 .deb to NixOS”;
};

outputs = { self, nixpkgs, home-manager, p81, …}:
let
lib = nixpkgs.lib;
system = “x86_64-linux”;
pkgs = nixpkgs.legacyPackages.${system};
in {
nixosConfigurations = {
nixos = lib.nixosSystem {
inherit system;
modules = [ ./configuration.nix p81.perimeter81 ];
};
};
homeConfigurations = {
jwomack = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home.nix ];
};
};
};

}

Any additional direction will be greatly appreciated.

Yes, NixOS modules from flakes are exposed under the nixosModules attribute, so you need:

modules = [ ./configuration.nix p81.nixosModules.perimeter81 ];

You can see the precise location in the flake source here.


By the way, you can enclose code in blocks like this for easier reading:

```nix
{foo = 1;}
```

Updating the version is a bit trickier.

You can swap out the package for a newer one using the module’s package option.

Unfortunately the flake does not expose the unwrapped package inside the FHS env wrapper so we need to call the source nix file directly.

modules = [
  ./configuration.nix

  p81.nixosModules.perimeter81

  ({ pkgs, ... }: {
    services.perimeter81 = {
      enable = true;

      package = p81.packages.${system}.perimeter81.override {
        perimeter81-unwrapped = (pkgs.callPackage "${p81}/perimeter81.nix" {}).overrideAttrs (oldAttrs: rec {
          version = "9.0.1.843";
          src = builtins.fetchurl {
            url = "https://static.perimeter81.com/agents/linux/Perimeter81_${version}.deb";
            sha256 = "sha256:0ys2w2yqsb45lzjrnbq9x880w1c0vn0s9chrb9w9773h4062p3ji";
          };
        });
      };
    };
  })
];

You can now adjust the version directly (and don’t forget to update the sha256).