Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flake #77

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/artifacts
CMakeLists.txt.user*
.*.swp
flake.lock
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Binary packages for Linux, macOS and Windows are available on the [release page]

[release page]: https://github.com/agateau/nanonote/releases

It is also possible to use it as a flake. See the [example](nix/example.nix) in the nix folder.
The flake is only teted on x86 linux, but should work on all nix system types.

## Tips and tricks

Even if Nanonote has a minimalist user interface, it comes with some handy shortcuts. Learn more about them from the [tips and tricks page](docs/tips.md).
Expand Down
62 changes: 62 additions & 0 deletions nix/example.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# This example flake does probably not work. But it should make it clear how to add Nanonote
# to your system flake, to be able to install Nanonote on your nix system.

{
description = "An example flake for Nanonote";

inputs = {

# General nixpkgs inputs:
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";

# Home-mamanger inputs
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";

# Adding the nanonote flake input
nanonote.url = "github:Morgenkaff/nanonote/add-flake?dir=nix";

};

outputs = { nixpkgs, home-manager, nanonote, ... }@inputs:

let

# Set the system you are using here.
# This can be set in multiple ways, this is just one example.
system = "x86_64-linux";

in {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [

# Create an overlay to install Nanonote as was it part of nixpkgs
({ nixpkgs.overlays = [ nanonote.overlays.default ]; })
# And then install it under "environment.systemPackages" in your nix configuration


# Nix cinfiguration
./configuration.nix

# Home-manager config:
home-manager.nixosModules.home-manager
{

# Alternatively create n overlay for use in Home-manager
nixpkgs.overlays = [ nanonote.overlays.default ];
# And then install it under "home.packages" in you Home-manager configuration

home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.user = import ./home-manager.nix;

}
};
};
};
}

92 changes: 92 additions & 0 deletions nix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
description = "A flake for Nanonote";

outputs = { self, nixpkgs }:
let

# Set a var for the version/release number for nanonote
# This is used to name the package and declare which release
# of nanonote to use. Using the tag here:
version = "1.4.1";

# List of supported systems:
supportedSystems = [
"x86_64-linux"# src = fetchgit {
# url = "https://github.com/agateau/nanonote";
# rev = "${version}";
# sha256 = "MsVHu3lAe/aGzFt1xDrsZHzLF1ysjhRUfruypoXEEnU=";
# fetchSubmodules = true;
# };
Morgenkaff marked this conversation as resolved.
Show resolved Hide resolved

"aarch64-linux"
"x86_64-darwin"
"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; });
pkgs = nixpkgs;

in
{
# Create the package output for all system architectures
packages = forAllSystems (system:
let
# Set pkg as nixpkgs for correct system architectures
pkgs = nixpkgsFor.${system};
in
{

# Declare a default package (there's only one package in this flake..)
default = self.packages.${system}.nanonote;

# Write derivation for nanonote.
# Declaring the src, name, built dependencies etc
nanonote = with pkgs; pkgs.stdenv.mkDerivation rec {

# Set the package name with "version" appended
name = "nanonote";

# This is a bit silly solution..
# But it seemed to be the easiest way to fetch the submodules too.
src = fetchgit {
url = "https://github.com/agateau/nanonote";
rev = "${version}";
sha256 = "MsVHu3lAe/aGzFt1xDrsZHzLF1ysjhRUfruypoXEEnU=";
fetchSubmodules = true;
};


# These are the packages needed to build nanonote
nativeBuildInputs = [
cmake
extra-cmake-modules
libsForQt5.qt5.qtbase
libsForQt5.qt5.qttools
libsForQt5.qt5.wrapQtAppsHook
git
];

# Command to build nanonote (with a core limitation, just to be safe)
buildPhase = ''
make -j $NIX_BUILD_CORES
'';

# And make install, to get all the pieces tp the wight places.
# $out is the nix store/derivation output (don't know what it's called)
installPhase = ''
make install PREFIX=$out
'';
};
}
);

# At last declaring the overlay used in the recieving/consuming flakes
overlays.default = final: prev: {
nanonote = self.packages.${prev.system}.nanonote;
};

};

}
Loading