Skip to content

Commit

Permalink
style: Apply nixfmt-rfc-style to all *.nix files
Browse files Browse the repository at this point in the history
  • Loading branch information
akirak committed Jul 27, 2024
1 parent ba8a16d commit f752305
Show file tree
Hide file tree
Showing 13 changed files with 522 additions and 496 deletions.
63 changes: 34 additions & 29 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,41 @@
src.url = "github:akirak/flake-templates";
};

outputs = {
self,
systems,
nixpkgs,
pre-commit-hooks,
...
} @ inputs: let
eachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = eachSystem (system: {
update-beam = nixpkgs.legacyPackages.${system}.callPackage ./update-beam.nix {};
});
outputs =
{
self,
systems,
nixpkgs,
pre-commit-hooks,
...
}@inputs:
let
eachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
packages = eachSystem (system: {
update-beam = nixpkgs.legacyPackages.${system}.callPackage ./update-beam.nix { };
});

checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = inputs.src.outPath;
hooks = {
actionlint.enable = true;
alejandra.enable = true;
markdownlint.enable = true;
checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = inputs.src.outPath;
hooks = {
actionlint.enable = true;
alejandra.enable = true;
markdownlint.enable = true;
};
};
};
});
});

devShells = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
};
devShells = eachSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell { inherit (self.checks.${system}.pre-commit-check) shellHook; };
}
);
};
}
49 changes: 30 additions & 19 deletions dev/update-beam.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
/*
This script helps the user keep Erlang (erlangRxx) and Elixir (elixir_x_xx)
to their latest versions. It performs simple regexp substitutions in flake.nix.
This script helps the user keep Erlang (erlangRxx) and Elixir (elixir_x_xx)
to their latest versions. It performs simple regexp substitutions in flake.nix.
*/
{
lib,
beam,
writeText,
writeShellScript,
}: let
inherit (builtins) attrNames filter match sort head compareVersions;
}:
let
inherit (builtins)
attrNames
filter
match
sort
head
compareVersions
;

latestPackageMatching = pattern: attrs:
latestPackageMatching =
pattern: attrs:
lib.pipe attrs [
(lib.filterAttrs (name: _: match pattern name != null))
(lib.mapAttrsToList (name: value: {
inherit name;
inherit (value) version;
}))
(lib.mapAttrsToList (
name: value: {
inherit name;
inherit (value) version;
}
))
(sort (a: b: compareVersions a.version b.version > 0))
(elems: builtins.elemAt elems 1)
(x: x.name)
Expand All @@ -35,14 +46,14 @@ to their latest versions. It performs simple regexp substitutions in flake.nix.
s/${elixirRegex}/${latestElixir}/
'';
in
writeShellScript "update-beam" ''
git add .
find -name flake.nix | xargs sed -i -r -f ${sed}
writeShellScript "update-beam" ''
git add .
find -name flake.nix | xargs sed -i -r -f ${sed}
if git diff --exit-code
then
exit 1
else
git add .
fi
''
if git diff --exit-code
then
exit 1
else
git add .
fi
''
171 changes: 89 additions & 82 deletions elixir-app/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,103 @@
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
};

outputs = {
self,
nixpkgs,
systems,
flake-parts,
...
} @ inputs: let
# Set the Erlang version
erlangVersion = "erlang_25";
# Set the Elixir version
elixirVersion = "elixir_1_15";
in
flake-parts.lib.mkFlake {
inherit inputs;
} {
outputs =
{
self,
nixpkgs,
systems,
flake-parts,
...
}@inputs:
let
# Set the Erlang version
erlangVersion = "erlang_25";
# Set the Elixir version
elixirVersion = "elixir_1_15";
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;

imports = [
inputs.process-compose-flake.flakeModule
];
imports = [ inputs.process-compose-flake.flakeModule ];

perSystem = {
# self',
config,
system,
pkgs,
lib,
...
}: {
# Define a consistent package set for development, testing, and
# production.
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [
(final: _: let
erlang = final.beam.interpreters.${erlangVersion};
beamPackages = final.beam.packages.${erlangVersion};
elixir = beamPackages.${elixirVersion};
in {
inherit erlang elixir;
# Hex is not used in the devShell.
# inherit (beamPackages) hex;
})
];
};
perSystem =
{
# self',
config,
system,
pkgs,
lib,
...
}:
{
# Define a consistent package set for development, testing, and
# production.
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [
(
final: _:
let
erlang = final.beam.interpreters.${erlangVersion};
beamPackages = final.beam.packages.${erlangVersion};
elixir = beamPackages.${elixirVersion};
in
{
inherit erlang elixir;
# Hex is not used in the devShell.
# inherit (beamPackages) hex;
}
)
];
};

# You can build your Elixir application using mixRelease.
# packages.default = { };
# You can build your Elixir application using mixRelease.
# packages.default = { };

# Add dependencies to develop your application using Mix.
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; (
[
erlang
elixir
# You are likely to need Node.js if you develop a Phoenix
# application.
nodejs
# Add the language server of your choice.
inputs.lexical.packages.${system}.default
# I once added Hex via a Nix development shell, but now I install
# and upgrade it using Mix. Hex installed using Nix can cause an
# issue if you manage Elixir dependencies using Mix.
]
# Add a dependency for a file watcher if you develop a Phoenix
# application.
++ lib.optional stdenv.isLinux inotify-tools
++ (
lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
CoreServices
])
)
);
};
# Add dependencies to develop your application using Mix.
devShells.default = pkgs.mkShell {
buildInputs =
with pkgs;
(
[
erlang
elixir
# You are likely to need Node.js if you develop a Phoenix
# application.
nodejs
# Add the language server of your choice.
inputs.lexical.packages.${system}.default
# I once added Hex via a Nix development shell, but now I install
# and upgrade it using Mix. Hex installed using Nix can cause an
# issue if you manage Elixir dependencies using Mix.
]
# Add a dependency for a file watcher if you develop a Phoenix
# application.
++ lib.optional stdenv.isLinux inotify-tools
++ (lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreFoundation
CoreServices
]
))
);
};

# You can define background processes in Nix using
# process-compose-flake.
process-compose.example = {
settings = {
processes = {
ponysay.command = ''
while true; do
${lib.getExe pkgs.ponysay} "Enjoy our ponysay demo!"
sleep 2
done
'';
# You can define background processes in Nix using
# process-compose-flake.
process-compose.example = {
settings = {
processes = {
ponysay.command = ''
while true; do
${lib.getExe pkgs.ponysay} "Enjoy our ponysay demo!"
sleep 2
done
'';
};
};
};
};
};
};
}
Loading

0 comments on commit f752305

Please sign in to comment.